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

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?
LVL 1
Jazzy 1012Asked:
Who is Participating?
 
Julian HansenConnect With a Mentor Commented:
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
 
Julian HansenCommented:
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
 
Jazzy 1012Author Commented:
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Julian HansenCommented:
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
 
Jazzy 1012Author Commented:
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
 
Julian HansenCommented:
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
 
Jazzy 1012Author Commented:
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
 
Jazzy 1012Author Commented:
I get the error of  undefined id in the jasmine/index.php file
0
 
Jazzy 1012Author Commented:
called from jasmine/index.php?
0
 
Jazzy 1012Author Commented:
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
 
Julian HansenCommented:
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
 
Jazzy 1012Author Commented:
I Know I did the ajax wrong, thanks
0
 
Jazzy 1012Author Commented:
Could you take a look at my other question?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.