Jump to content

[SOLVED] Help with a loop


kevincro

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/73262-solved-help-with-a-loop/
Share on other sites

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.

 

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>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.