Jump to content

Update Multiple Rows On Submit


phpretard

Recommended Posts

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!

 

 

Link to comment
https://forums.phpfreaks.com/topic/211592-update-multiple-rows-on-submit/
Share on other sites

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>

 

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.