Hemlock Posted December 6, 2009 Share Posted December 6, 2009 I was wondering, I want to make a set of links on my page, which basically hold a value (number in this case), which I want to if clicked to be presented on the second page which the links are all directed to.so far I have the following <?php for ($i=0; $i<3; $i++) echo "<a href='page2.php' name='link'>Clickable Link</a>" . "<br />"; ?> this makes the links for me, but I really have no clue how I would go about attaching a number that I want to display on the second page goes. Link to comment Share on other sites More sharing options...
jeffman Posted December 6, 2009 Share Posted December 6, 2009 If your link looks like this:<a href='page2.php?something' name='link'>On page2.php you can find "?something" in location.search Link to comment Share on other sites More sharing options...
Ingolme Posted December 6, 2009 Share Posted December 6, 2009 I was wondering, I want to make a set of links on my page, which basically hold a value (number in this case), which I want to if clicked to be presented on the second page which the links are all directed to.so far I have the following <?php for ($i=0; $i<3; $i++) echo "<a href='page2.php' name='link'>Clickable Link</a>" . "<br />"; ?> this makes the links for me, but I really have no clue how I would go about attaching a number that I want to display on the second page goes. You just need to put the variable in the string you're outputting:for ($i=0; $i<3; $i++) { echo "<a href='page{$i}.php' name='link'>Clickable Link</a>" . "<br />";} Link to comment Share on other sites More sharing options...
Hemlock Posted December 7, 2009 Author Share Posted December 7, 2009 What if I wanted all links to always go to page2, but only represent the number in plain html text? Link to comment Share on other sites More sharing options...
Ingolme Posted December 7, 2009 Share Posted December 7, 2009 You have to add the number to the query string of the URL. In the other page, you access the number with the $_GET array:First page: for ($i=0; $i<3; $i++) { echo "<a href='page2.php?id={$i}' name='link'>Clickable Link</a>" . "<br />";} page2.php: if(isset($_GET['id'])) { echo $_GET['id'];} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.