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 Link to comment https://forums.phpfreaks.com/topic/96717-passing-data-with/ 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 Link to comment https://forums.phpfreaks.com/topic/96717-passing-data-with/#findComment-494891 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. Link to comment https://forums.phpfreaks.com/topic/96717-passing-data-with/#findComment-494894 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... Link to comment https://forums.phpfreaks.com/topic/96717-passing-data-with/#findComment-494910 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. Link to comment https://forums.phpfreaks.com/topic/96717-passing-data-with/#findComment-495128 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> Link to comment https://forums.phpfreaks.com/topic/96717-passing-data-with/#findComment-495136 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 Link to comment https://forums.phpfreaks.com/topic/96717-passing-data-with/#findComment-495163 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 Link to comment https://forums.phpfreaks.com/topic/96717-passing-data-with/#findComment-495165 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.