phpretard Posted August 24, 2010 Share Posted August 24, 2010 Only the last row will update when I submit. I have this form (and one nerve left): <form action="" method="post" > echo" <input style=\"text-align:center\" type=\"text\" name=\"linkorder\" value=\"".$row['order']."\" /> <input type=\"hidden\" name=\"id\" value=\"".$row['id']."\"/> "; <input type="submit" name="updateorder" value="Save Order" /> </form> On Submit: if (isset($_POST['updateorder'])){ connect(); $changeorder = mysql_unbuffered_query("update links set `order` = '".$_POST['linkorder']."' where id = '".$_POST['id']."'") or die(mysql_error()); } I was going put my fist through the monitor but then I remembered I could get help here. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/211592-update-multiple-rows-on-submit/ Share on other sites More sharing options...
Adam Posted August 24, 2010 Share Posted August 24, 2010 The code you provided doesn't give much away, but that query to me looks as though it should only update 1 row? Where exactly do the multiple values come from? Quote Link to comment https://forums.phpfreaks.com/topic/211592-update-multiple-rows-on-submit/#findComment-1103039 Share on other sites More sharing options...
phpretard Posted August 24, 2010 Author Share Posted August 24, 2010 I did hold out some info (my bad)... Here is the code in full. if (isset($_POST['updateorder'])){ connect(); $changeorder = mysql_unbuffered_query("update links set `order` = '".$_POST['linkorder']."' where id = '".$_POST['id']."'") or die(mysql_error()); } <form action="" method="post" autocomplete="off"> <table class="links" width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td align="center" class="label">ORDER</td> <td class="label">LINK NAME</td> </tr> <? connect(); $display = mysql_query("select * from links order by `order`") or die(mysql_error()); while($row = mysql_fetch_assoc($display)){ echo" <tr onMouseover=\"this.style.backgroundColor='pink';\" onMouseout=\"this.style.backgroundColor='';\"> <td align=\"center\"> <input style=\"text-align:center\" type=\"text\" name=\"linkorder\" value=\"".$row['order']."\" size=\"2\" /> <input type=\"hidden\" name=\"id\" value=\"".$row['id']."\"/> </td> <td>".$row['link']."</td> </tr> "; } free($display); ?> </table> <input type="submit" name="updateorder" value="Save Order" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/211592-update-multiple-rows-on-submit/#findComment-1103040 Share on other sites More sharing options...
phpretard Posted August 24, 2010 Author Share Posted August 24, 2010 Bump ... Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/211592-update-multiple-rows-on-submit/#findComment-1103227 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.