Solved

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

Posted on 2016-10-07
13
55 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
13 Comments
 
LVL 58

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 58

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 58

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
 
LVL 58

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 58

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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

617 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