noob qustion about passing values to other pages..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Strobe74
Forum Newbie
Posts: 3
Joined: Thu Jan 09, 2003 12:22 pm

noob qustion about passing values to other pages..

Post 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!
wreed
Forum Newbie
Posts: 12
Joined: Wed Dec 18, 2002 12:12 pm
Location: Butler, NJ
Contact:

Post 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]";
?>
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post 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?
Strobe74
Forum Newbie
Posts: 3
Joined: Thu Jan 09, 2003 12:22 pm

Post by Strobe74 »

Yes that was exactly what i was looking for. I knew you guys would be able to help. Thanks for the advice!
Post Reply