smeghead67 Posted November 22, 2010 Share Posted November 22, 2010 Hi, This is my first post here. I hope I can explain this so you fine people can help me. On my web page im building at home, I have it getting data from the mysql server and it displays it with no problems. I added a form button at the end of each table row. that will, my goal, direct a person to the page that displays the item info. for ($i=1;$i<=6;$i++) { $row = mysql_fetch_array($result); extract($row); $f_price = number_format($msrp,2); $f_hb = number_format($high_bid,2); check_time_left($itemid); echo "<tr>\n <td>$itemname</td>\n <td align='right'>\$$f_price</td>\n <td>$tlstring</td>\n <td align='right'>\$$f_hb</td>\n <td><form action='item.php' method='POST'> <input type='hidden' name='item_id' value='$itemid'> <input type='submit' value='view'></td> </tr>\n"; echo "<tr><td colspan='5'><hr></td></tr>\n"; } echo "</table>\n"; when i hit any button it always displays the info from the last item on my list? It does the same on another page with a while loop any ideas? Thank You Smeghead67 Quote Link to comment https://forums.phpfreaks.com/topic/219423-form-button-in-loop/ Share on other sites More sharing options...
haku Posted November 22, 2010 Share Posted November 22, 2010 1) Please don't post PHP scripts in the HTML section. When you have an HTML question, the PHP is irrelevant. Post the output of your PHP script. 2) If you look at the HTML output of your script, it will probably quickly apparent to you why you are only seeing the value of the last item (hint: look at the 'name' attribute of two of the form elements from your loop). Quote Link to comment https://forums.phpfreaks.com/topic/219423-form-button-in-loop/#findComment-1137833 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.