944,219 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 45075
  • PHP RSS
Aug 15th, 2007
0

Passing a value via href - php

Expand Post »
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
PHP Syntax (Toggle Plain Text)
  1. http://www.mypage.com/view.php?prop_id=5
and I want to add a link, that would translate to
PHP Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Binary is offline Offline
3 posts
since Apr 2006
Aug 15th, 2007
0

Re: Passing a value via href - php

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.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Aug 15th, 2007
0

Re: Passing a value via href - php

Click to Expand / Collapse  Quote originally posted by Ezzaral ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Binary is offline Offline
3 posts
since Apr 2006
Aug 15th, 2007
0

Re: Passing a value via href - php

Click to Expand / Collapse  Quote originally posted by Binary ...
If I am on this page for example
PHP Syntax (Toggle Plain Text)
  1. http://www.mypage.com/view.php?prop_id=5
and I want to add a link, that would translate to
PHP Syntax (Toggle Plain Text)
  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 :

php Syntax (Toggle Plain Text)
  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.
Reputation Points: 59
Solved Threads: 12
Junior Poster
MitkOK is offline Offline
142 posts
since Jul 2007
Aug 16th, 2007
0

Re: Passing a value via href - php

Click to Expand / Collapse  Quote originally posted by MitkOK ...
What do you mean by trabslate ?

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

php Syntax (Toggle Plain Text)
  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:

php Syntax (Toggle Plain Text)
  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
php Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Binary is offline Offline
3 posts
since Apr 2006
Aug 16th, 2007
0

Re: Passing a value via href - php

Click to Expand / Collapse  Quote originally posted by Binary ...
I get the link with the prop_id variable. However I want to point something out, if I try to use for example
php Syntax (Toggle Plain Text)
  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.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Apr 22nd, 2009
0

Re: Passing a value via href - php

Click to Expand / Collapse  Quote originally posted by Ezzaral ...
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
PHP Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maheen123 is offline Offline
13 posts
since Apr 2009
Dec 20th, 2010
0
Re: Passing a value via href - php
I have a similar question. I am passing the ?id=%s to the href link. I want to pick up that id number later. How do I retrieve that number so I can use that id to display specific table data on the page? Hope you understand.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
darrell1226 is offline Offline
1 posts
since Dec 2010
Dec 20th, 2010
0
Re: Passing a value via href - php
as above, the $_GET array contains the parameters passed in the url
to get the value ?id=%s
php Syntax (Toggle Plain Text)
  1. echo $_GET['id'];
  2. /* or if the id is being used more often than once assign it as a variable */
  3. $id = $get['id'];
  4. echo $id;
  5. /* do some math */ + $id; // bla bla bla
Hth

referring to $_request, $_post, $_get in the php online manuals may provide useful code samples
Last edited by almostbob; Dec 20th, 2010 at 10:25 pm.
Reputation Points: 562
Solved Threads: 369
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP MySQL Module Generator - Guys Please take a look. It might help you =)
Next Thread in PHP Forum Timeline: dropdown list





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC