kevincro Posted October 15, 2007 Share Posted October 15, 2007 I'm trying to add the following link to my display page. <a href="applyforstake.php?item_id=1>Apply" This is the code taken directly from the display page: echo "<td>"."<a href="applyforstake.php?item_id=1">Apply"."</td>"; This code works well for displaying the link in my display page, however, I want the item_id to be equal to the auto_increment column on each row. In other words, for the first row on the display page, the item_id will be 1, the second row item_id should be 2 and so on for however many rows are in the table. How do I accomplish this. Quote Link to comment https://forums.phpfreaks.com/topic/73262-solved-help-with-a-loop/ Share on other sites More sharing options...
peeps Posted October 15, 2007 Share Posted October 15, 2007 Give this a try: $counter = 30; for ($id = 0; $id < $counter; $id++) { echo "<td>"."<a href=\"applyforstake.php?item_id=$id\">Apply"."</td> <br>"; } Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/73262-solved-help-with-a-loop/#findComment-369660 Share on other sites More sharing options...
kevincro Posted October 15, 2007 Author Share Posted October 15, 2007 I'm confident that this solution will work with some tweeking. As it stands, when I try it, it puts 30 apply buttons on each displayed row, each button having a unique $id. I'll play around with it and see what I can come up with. I'll post the results. Thanks so much for your help. I've been 4 days trying to get this to work. lol. Quote Link to comment https://forums.phpfreaks.com/topic/73262-solved-help-with-a-loop/#findComment-369675 Share on other sites More sharing options...
kevincro Posted October 15, 2007 Author Share Posted October 15, 2007 Okay this is rather embarrassing. This is all I had to do the whole time. I had tried something similar but apparently didn't have my variable in the right spot. $id = $row['indexcolumname']; echo "<td>"."<a href=\"applyforstake.php?item_id=$id\">Apply"."</td> <br>"; Quote Link to comment https://forums.phpfreaks.com/topic/73262-solved-help-with-a-loop/#findComment-369680 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.