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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.