I have a dynamic rows coming from the database. each row has an order field. I want to make the user able to change the order by entering the order in text boxes show’s next to each row, and when the user click save each row will be updated with the new order.
My problem is when I wrote this code:
<table>
<?
foreach($results as $p)
{
echo '
<tr>
<td>'.$p['page_title'].'</td>
<td><input type="text" size="2" id="'.$p['page_id'].'" name="s[]" value="'.$p['menu_order'].'"></td>
</tr>';
}
?>
<tr><td colspan="2"><input type="submit" value="Save Order"></td></tr>
</table>
as you can see that every dynamic text box would give the the new order after posting the form, but the Question is how I can know this order to which row ?
the image would explain more. After I clicked Save the s array would be like this:
Array ( [0] => 2 1 => 3 [2] => 1 )
However, I cannot know the page that I want to update !!

I think what you are asking is how to order the fields by the number assigned to it. If that’s what you are looking to do and if you are using MySQL to store this data you can just retreive it in that order. For example:
Edit: Now that I have re-read your question you also might be asking how to assign that order to each row. I noticed that your fields are named
s[]You could name them$p['page_id']and update them accordingly.And then