Solved

Make my code go to a certain link and input the date

Posted on 2016-10-07
13
29 Views
Last Modified: 2016-10-08
I have this code:
$query="Select name,date,service_dos,code from vouchers LEFT JOIN voucher_pay ON vouchers.voucher_id=voucher_pay.voucher_id LEFT JOIN pay_details ON voucher_pay.payment_id = pay_details.payment_id where paid_amount > 0 GROUP BY name,date,service_dos,code LIMIT 50";

$result = pg_query($conn,$query);
<thead>
	<tr>
		<th>Name</th>
		<th>Date </th>

	</tr>
</thead>
$website = 'http://jasmine.com';
         <td><?php echo'<a href="'.$website.'">'. $row['name']; ?></td>
         <td><?php echo $row['date']; ?></td>

Open in new window

This is how the calendar looks like
The output of my code is this:


                                 Name                                                   Date
                                 --------                                                 --------
3931550_SB621_1780690.510.100.6f8                      2015-04-11
NGS_ILDEB_20140728                                                      2014-09-29
3931550_SB621_187104.5010.103.a6b                      2015-01-04

With the names being links that send to jasmine. And in jasmine.com there's a calendar I want it to put the date that is displayed. Like for the first one to be "2015-04-11", Is there a way to do this?
0
Comment
Question by:Jasmine Ikhreishi
  • 8
  • 5
13 Comments
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41833666
Don't understand this bit
And in jasmine.com there's a calendar I want it to put the date that is displayed. Like for the first one to be "2015-04-11", Is there a way to do this?
0
 
LVL 1

Author Comment

by:Jasmine Ikhreishi
ID: 41833677
The calendar above is in jasmine.com, I want to send the name as a get parameter to jasmine, and by javascript for it to check and put it in the calendar, but im not sure how Im able to do this
For example for the first one itll send "2015-04-11" for that name and when i click on it ill find that date already ready for me I just need to click enter
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41833727
The calendar above is in jasmine.com,
I don't know what jasmine.com is or what it does.
I want to send the name as a get parameter to jasmine, and by javascript for it to check and put it in the calendar
By calendar do you mean the popup Date?

For example for the first one itll send "2015-04-11" for that name and when i click on it ill find that date already ready for me I just need to click enter
Find it where - what are you pressing enter on?
1
 
LVL 1

Author Comment

by:Jasmine Ikhreishi
ID: 41833738
Okay in document file1.php, I get the table I put above, each name is clickable to "Jasmine.com",  in jasmine/index.php, I get the popup date.
so now for example if i click on 3931550_SB621_1780690.510.100.6f8 (from the file.php table) when I go to jasmine the date "2015-04-11" Would appear in the popup. So far I put in file1.php:
function fileName(id){
	     var scriptUrl = "http://jasmine/index.php?id=" + id;
	     $.ajax({
	        url: scriptUrl,
	        type: 'get',
	        dataType: 'html',
	        async: false,
	        success: function(data) {
	        result = data;
	        } 
	     });
	     return result;
	} 

Open in new window


And in jasmine I put:
$id=$_GET['id'];

Open in new window


Im unsure whats the next step.
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41833795
Ok, lets try this another way.

When you click on the link - does the page navigate to another page - trying to figure out where the AJAX comes in?
So you are on the page with the links (file1.php)- you click the link - can you show me what the link looks like.
0
 
LVL 1

Author Comment

by:Jasmine Ikhreishi
ID: 41833809
Okay so it does send me to the link(jasmine/index.php) and this is how the website looks like:
And when I click on the posting date, that calendar popup appears and then you chose the date.
So far I have in file.php is this:
<script>
function fileName(id){
	     var scriptUrl = "http://52.91.139.19/835_validate/index.php?id=" + id;
	     $.ajax({
	        url: scriptUrl,
	        type: 'get',
	        dataType: 'html',
	        async: false,
	        success: function(data) {
	        result = data;
	        } 
	     });
	     return result;
	} 
</script>

Open in new window


And in jasmine/index.php:
<?php 
require "connection.php";
$id=$_GET['id'];

$query5="Select name,datecode from vouchers LEFT JOIN voucher_pay ON vouchers.voucher_id=voucher_pay.voucher_id LEFT JOIN pay_details ON voucher_pay.payment_id = pay_details.payment_id where name = '" . $id . "' GROUP BY name,date,code";

$result5 = pg_query($conn,$query5);
$row5 = pg_fetch_array($result5);
echo $row5['date'];
?>

Open in new window


It worked by just always send the first date which is "2015-04-11" Because I forgot to put where name = '" . $id . "' but when i put it, it doesnt display anything anymore, Also how can I put them inside the calendar instead of displaying on top
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41833825
If I understand you correctly when you click on a link it is making an AJAX call to the server to get a date - so you stay on file1.php you are calling to index.php only through AJAX - is that correct?

Can you show me how the function fileName is called?
0
 
LVL 1

Author Comment

by:Jasmine Ikhreishi
ID: 41833862
I get the error of  undefined id in the jasmine/index.php file
0
 
LVL 1

Author Comment

by:Jasmine Ikhreishi
ID: 41833868
called from jasmine/index.php?
0
 
LVL 1

Author Comment

by:Jasmine Ikhreishi
ID: 41833872
This is all I have on jasmine/index.php

<?php 
error_reporting(E_ALL);
ini_set('display_errors' ,1);
require "connection.php";

$id=$_GET['id'];


$query5="Select name,date from vouchers where name = '" . $id . "'";

$result5 = pg_query($conn,$query5);
$row5 = pg_fetch_array($result5);
echo $row5['date'];
?>

Open in new window

0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41833924
Ok so the index.php just returns a date.

Are you still getting undefined.

If I browse to view-source:http://52.91.139.19/835_validate/index.php?id=1
I get a page similar to the screen shot you showed me above.

Which confuses me as to why you are using AJAX to call this page?
0
 
LVL 1

Author Comment

by:Jasmine Ikhreishi
ID: 41834984
I Know I did the ajax wrong, thanks
0
 
LVL 1

Author Comment

by:Jasmine Ikhreishi
ID: 41835000
Could you take a look at my other question?
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now