Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP/SQL pass value to field on linked page



11:03 am on Mar 22, 2005 (gmt 0)

10+ Year Member

Sorry if this has been asked before (I did do a search first!)

I have setup an sql table containing project data (job no, description, date and auto-number id) which displays in rows on my main page. Next to each project is a link which a user can click to submit their details to show interest in that particular project. When they click this link they are taken to another page with a contact form, but I need to automatically show the job no of the project they selected in this form. I have successfully got the job no for the 1st record in the table into the field but need to make it dynamic.

How do I get the correct job no according to the link they click?



11:55 am on Mar 22, 2005 (gmt 0)

10+ Year Member

it appears you need to pass some data in the actual link. You can accomplish this by passing arguments on the link like ...


then on the newpage.php, add code that would check for the value of the query string using $_GET; e.g. $_GET['var'] and $_GET['row'] from here you can add your script on what you want to do with the data passed on the link.


11:56 am on Mar 22, 2005 (gmt 0)

10+ Year Member

By $_GET or $_POST on your receiving page, depending on the METHOD you used on your selection form.
In the form SELECT you need to assign a name to the value selected, then GET it on the next page.


12:02 pm on Mar 22, 2005 (gmt 0)

10+ Year Member

When I generate the link, I append the variables to the end of the URL after a delimiter of some kind. (I use 2 backticks) Then I pull the URL on the following page, and get out that information.

Here is what your hyperlink would look like

At the beginning of the following page's code:

$vars = get_url_vars(); //my function
parse_str($vars); //php function
then you can access $cat and $col in the code.

here is my declared function

function get_url_vars()
$temp_url = $_SERVER['PHP_SELF'];
$rip = explode('``',$temp_url);
return $rip[1];

It may not be the best way to do it, and certainly not the only way...but when I was there, this is how I solved the problem. (I also put in a check for control characters in the variables on each page...but I couldn't get any through anyway when I was testing)


1:21 pm on Mar 22, 2005 (gmt 0)

10+ Year Member

Thanks everyone! Very easy to follow - even for a newbie...



Featured Threads

Hot Threads This Week

Hot Threads This Month