phplearner2008 Posted September 29, 2008 Share Posted September 29, 2008 Hi, I have a variable $id which i would like to send to mypage.php. Can anyone tell me how to do it? <a href = "http://localhost/mypage.php?id=$id">MyPage</a> doesn't seem to work. Link to comment https://forums.phpfreaks.com/topic/126236-solved-how-to-send-variable-through-link/ Share on other sites More sharing options...
ratcateme Posted September 29, 2008 Share Posted September 29, 2008 how are you retreving it at mypage.php it should be like this $id = $_GET['id']; echo $id; Scott. Link to comment https://forums.phpfreaks.com/topic/126236-solved-how-to-send-variable-through-link/#findComment-652776 Share on other sites More sharing options...
phplearner2008 Posted September 29, 2008 Author Share Posted September 29, 2008 <?php while($row = mysql_fetch_array($result)) { $id = $row['name']; } ?> <a href="http://localhost/mypage.php?id=$id">Mypage</a> In mypage.php, $myid = $_GET['id']; echo "$myid"; This is the code I am trying to execute. Any suggestions? Link to comment https://forums.phpfreaks.com/topic/126236-solved-how-to-send-variable-through-link/#findComment-652782 Share on other sites More sharing options...
ranjuvs Posted September 29, 2008 Share Posted September 29, 2008 Try this <a href = "http://localhost/mypage.php?id="<?php print $id ?>>MyPage</a> Link to comment https://forums.phpfreaks.com/topic/126236-solved-how-to-send-variable-through-link/#findComment-652786 Share on other sites More sharing options...
phplearner2008 Posted September 29, 2008 Author Share Posted September 29, 2008 Thank you ranjuvs, I made a small change to your code and it worked! Instead of <a href = "http://localhost/mypage.php?id="<?php print $id ?>>MyPage</a> I put ending quotes at end of php like this <a href = "http://localhost/mypage.php?id=<?php print $id ?>">MyPage</a> My problem is solved Link to comment https://forums.phpfreaks.com/topic/126236-solved-how-to-send-variable-through-link/#findComment-652788 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.