Passing a value via href - php

Reply

Join Date: Apr 2006
Posts: 3
Reputation: Binary is an unknown quantity at this point 
Solved Threads: 0
Binary Binary is offline Offline
Newbie Poster

Passing a value via href - php

 
0
  #1
Aug 15th, 2007
I recently started working with PHP, and MySQL. And I have come with a little problem, I have tried a couple of things to solve it and they are not working. Well, basically I am trying to put a link on a page, but that page requires me to pass a value, here's an example below, e.g.

If I am on this page for example
  1. http://www.mypage.com/view.php?prop_id=5
and I want to add a link, that would translate to
  1. <a href="submit_docs.php?prop_id=5 ">Click </a>
How do I accomplish this, how do I pass the php variable "prop_id" to a href link? Can someone shed me some light on this matter? Thanks a lot
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Passing a value via href - php

 
0
  #2
Aug 15th, 2007
Um, you do it exactly like you have indicated in your link. I'm not certain what your question is exactly. Are you unsure how to build the link string? Unsure how to retrieve the value in the target page? Please elaborate a bit.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 3
Reputation: Binary is an unknown quantity at this point 
Solved Threads: 0
Binary Binary is offline Offline
Newbie Poster

Re: Passing a value via href - php

 
0
  #3
Aug 15th, 2007
Originally Posted by Ezzaral View Post
Um, you do it exactly like you have indicated in your link. I'm not certain what your question is exactly. Are you unsure how to build the link string? Unsure how to retrieve the value in the target page? Please elaborate a bit.
Yes, I am not sure how to build the link string that would pass the prop_id=[current_id_value] variable. I typed the prop_id=5 as an example, technically it could be any number. I am guessing there is a way to get the variable from the MySQL database, but once I get it, how do it build the link. Thanks again
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 142
Reputation: MitkOK is an unknown quantity at this point 
Solved Threads: 12
MitkOK's Avatar
MitkOK MitkOK is offline Offline
Junior Poster

Re: Passing a value via href - php

 
0
  #4
Aug 15th, 2007
Originally Posted by Binary View Post
If I am on this page for example
  1. http://www.mypage.com/view.php?prop_id=5
and I want to add a link, that would translate to
  1. <a href="submit_docs.php?prop_id=5 ">Click </a>
How do I accomplish this, how do I pass the php variable "prop_id" to a href link? Can someone shed me some light on this matter? Thanks a lot
What do you mean by trabslate ?

If you want to you use prop_id from view.php url in link :

  1. $prop_id = '$_GET[prop_id]';
  2.  
  3. echo "<a href=\"submit_docs.php?prop_id=".$prop_id."\">Click </a>";


- Mitko Kostov
Last edited by MitkOK; Aug 15th, 2007 at 5:59 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 3
Reputation: Binary is an unknown quantity at this point 
Solved Threads: 0
Binary Binary is offline Offline
Newbie Poster

Re: Passing a value via href - php

 
0
  #5
Aug 16th, 2007
Originally Posted by MitkOK View Post
What do you mean by trabslate ?

If you want to you use prop_id from view.php url in link :

  1. $prop_id = '$_GET[prop_id]';
  2.  
  3. echo "<a href=\"submit_docs.php?prop_id=".$prop_id."\">Click </a>";


- Mitko Kostov
It works! Thanks a lot Mitko, and everyone who viewed this post By using the code:

  1. echo "<a href=\"submit_docs.php?prop_id=".$prop_id."\">Click </a>";

I get the link with the prop_id variable. However I want to point something out, if I try to use for example
  1. $varid_id = '$_GET[prop_id]';
And used $varid_id instead of $prop_id I get an error, In other words, I did not have to declare $prop_id to use it in the link.
Again thanks a lot
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Passing a value via href - php

 
0
  #6
Aug 16th, 2007
Originally Posted by Binary View Post
I get the link with the prop_id variable. However I want to point something out, if I try to use for example
  1. $varid_id = '$_GET[prop_id]';
And used $varid_id instead of $prop_id I get an error, In other words, I did not have to declare $prop_id to use it in the link.
Again thanks a lot
He just included that as an example of retrieving prop_id from a GET page request. If prop_id had been passed in via a link, you would get it with that code. If you are generating the prop_id from another source, you wouldn't need to pull it from the $_GET[] array.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 13
Reputation: maheen123 is an unknown quantity at this point 
Solved Threads: 0
maheen123 maheen123 is offline Offline
Newbie Poster

Re: Passing a value via href - php

 
0
  #7
Apr 22nd, 2009
Originally Posted by Ezzaral View Post
Um, you do it exactly like you have indicated in your link. I'm not certain what your question is exactly. Are you unsure how to build the link string? Unsure how to retrieve the value in the target page? Please elaborate a bit.
Hi!
I have the similar prrob as described by Binary . But i want to edit any row value displayed in a form in the form of a table . Now i want to edit a specific field after selecting. But If I put an edit link before each row or whatever , how can i pass the relavent variable values to the called form... I want to know the syntax or in simple words i want to send variables in a link string.
Supoz i have
  1. echo "<td>".$row['lname']."</td>";
now how can i add an edit link to it that will make me able to edit a specfic field. DO i need to add it on row level?
Please help me
Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC