Page 1 of 1

noob qustion about passing values to other pages..

Posted: Tue Jan 14, 2003 12:18 pm
by Strobe74
I'm trying to find a way to pass a value to a page much like a form does when you submit user data, but without using a form. I have a script that returns data from a database and displays it out in this nice table. I need to be able to click on items in one of the columns (username) as a link and have it pass a value (the users name) to a new page so i can work with that value (basically sending it to a stored procedure in a MSSQL DB again).

The part I’m having a problem with is how to pass the username as a value to another .php page without using a form or starting a session (if possible). Is there an alternate way to submit a form by clicking a link or some way to pass a value from a function to a new page?

Any suggestions would be appreciated. Thanks!

Posted: Tue Jan 14, 2003 12:48 pm
by wreed
In my first page I use the link like this

Code: Select all

<?php
<A HREF="edit_process.php?id=$id">
?>
Then in the edit_process page I look the the variable in the link URL like this...

Code: Select all

<?php
$query = "SELECT * FROM tablename WHERE id = $_GET[id]";
?>

Posted: Tue Jan 14, 2003 1:25 pm
by Gen-ik
Just do something like this.. notice the position of the PHP tags unlike the previous example which I don't think would work!

Code: Select all

&lt;a href="target_page.php?colour=&lt;?php echo($colour); ?&gt;"&gt;Change Colour&lt;/a&gt;

..to echo() the entire bit from PHP code you would do this..

Code: Select all

<?php

echo("<a href="target_page.php?colour=".$colour."">Change Colour</a>");

?>
..does that make sense?

Posted: Tue Jan 14, 2003 3:00 pm
by Strobe74
Yes that was exactly what i was looking for. I knew you guys would be able to help. Thanks for the advice!