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

http://www.mypage.com/view.php?prop_id=5

and I want to add a link, that would translate to

<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 :)

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.

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 :)

If I am on this page for example

http://www.mypage.com/view.php?prop_id=5

and I want to add a link, that would translate to

<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 :

$prop_id = '$_GET[prop_id]';

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

- Mitko Kostov

What do you mean by trabslate ?

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

$prop_id = '$_GET[prop_id]';

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:

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

$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 :)

I get the link with the prop_id variable. However I want to point something out, if I try to use for example

$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.

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

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

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.

as above, the $_GET array contains the parameters passed in the url
to get the value ?id=%s

echo $_GET['id']; 
/* or if the id is being used more often than once assign it as a variable */
$id = $get['id'];
echo $id;
/* do some math */ + $id; // bla bla bla

Hth

referring to $_request, $_post, $_get in the php online manuals may provide useful code samples

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.