I've got a problem. Im making a list of stuff and everything on the list is a link that should link to the same page. I want to take that links name, text, whatever you want to call it to the next page but don't know how to do that.
Here's an example!
while($row = mysql_fetch_array($result)){
<td><a href=uppsatserInfo.php>" . $row['name'] . "</a>
}
The " $row['name'] " generates all the data from the row "name" in the database. As you can see, im making a link out of everything that is printed out. The link is to the page "uppsatserInfo.php" and I want to take the name of the link with me to that page, but how do I do that?
You can pass the name of the page as a GET parameter to uppsatserInfo.php
. Change this:
"<td><a href=uppsatserInfo.php>" . $row['name'] . "</a>"
to this:
"<td><a href='uppsatserInfo.php?name=" . urlencode($row['name']) . "'>" . $row['name'] . "</a>"
On uppsatserInfo.php
, the variable
$_GET['name']
will have the name of the page.
Just append it to the URL in the querystring:
echo "<td><a href='uppsatserInfo.php?name=" . urlencode($row['name']) . "'>" . $row['name'] . "</a></td>";
You get in on uppsatserInfo.php like so:
$name = $_GET['name'];
You still need too verify it is a valid value on that page as a user can easily alter this data.