RobertSubnet Posted March 18, 2008 Share Posted March 18, 2008 Greetings all. I am using mysql_fetch_array() and a while loop to retrieve data from a MySQL database. The loop is also used to populate an associative array. I would like to pass the retrieved data to another PHP script, preferably using an anchor tag with an href attribute. Is there a way to do this or am I stuck having to use a form/submit? Thanks, ~Robert Quote Link to comment Share on other sites More sharing options...
revraz Posted March 18, 2008 Share Posted March 18, 2008 You can pass with GET like mypage.php?id=1 Quote Link to comment Share on other sites More sharing options...
bpops Posted March 18, 2008 Share Posted March 18, 2008 Depending on how much data, you can pass it via a GET in an <a href> tag, however, the best thing to do would be to get the information from the table again on the second page based on the criteria given to the first page. Another option is to use sessions. Quote Link to comment Share on other sites More sharing options...
pauleth Posted March 18, 2008 Share Posted March 18, 2008 There's definitely no reason why you can't pass values to another script via an HTML anchor tag, and use PHP GET to extract the values from the URL. That method can get pretty messy though... Quote Link to comment Share on other sites More sharing options...
RobertSubnet Posted March 18, 2008 Author Share Posted March 18, 2008 So lets say I have a URL: \\mywebsite.com/firstpage.php In the firstpage.php script, I have a variable, $variable = 10 and I want to pass the value (10) to another script, lets say secondpage.php. Would the link on firstpage.php look like this: <a href = mywebsite.com/secondpage.php?variable = 10>Click Me</a> Then to access the $variable value (10) on secondpage.php, I would code it as: $variable_on_secondpage_php = $_GET['variable']; Thanks again. Quote Link to comment Share on other sites More sharing options...
bpops Posted March 18, 2008 Share Posted March 18, 2008 So lets say I have a URL: \\mywebsite.com/firstpage.php In the firstpage.php script, I have a variable, $variable = 10 and I want to pass the value (10) to another script, lets say secondpage.php. Would the link on firstpage.php look like this: <a href = mywebsite.com/secondpage.php?variable = 10>Click Me</a> Then to access the $variable value (10) on secondpage.php, I would code it as: $variable_on_secondpage_php = $_GET['variable']; Thanks again. yup! or to make sure the variable (whatever it is is passed), <a href="mywebsite.com/secondpage.php?variable=<?php echo $variable; ?>">Click Me</a> Quote Link to comment Share on other sites More sharing options...
RobertSubnet Posted March 18, 2008 Author Share Posted March 18, 2008 Great! Thanks again guys for your help! ~Robert Quote Link to comment Share on other sites More sharing options...
jkewlo Posted March 18, 2008 Share Posted March 18, 2008 you might want to use the @$_POST on the next page to get your info Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.