Jump to content

Hyperlinks and carrying a variable over


soullessj

Recommended Posts

What i need to do is in the hyperlink add a variable to be carried over ie. id = 2.

if im not mistaken i can just add a name tag and put id = 2 for it.

and then use that as the id variable in the next page.

 

then i need to tell the next page to use that variable so that i can use it in a sql query command to display data from the table where the id is 2 and show the relative information.

 

just need the hyperlink and how to include what that id variable will be so that i can query for just that information.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/238865-hyperlinks-and-carrying-a-variable-over/
Share on other sites

What you are doing is attempting to pass a GET parameter through the url. This is done using the following syntax:

 

<?php
$id = '1224';
<a href="http://www.somesite.com/somepage.php?id=$id"></a>
// you can append as many variables as you need. These have to be seperated by the & sign.
<a href="http://www.somesite.com/somepage.php?id=$id&id2=$id2.........."></a>

then on the page you are sending the variables to:

$id = $_GET['id];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.