Hi,
I have a table like this:
Table name: page
ID | name | status | order
1 | a-name | active | 1
2 | a-name | active | 2
3 | a-name | active | 3
The "name" is being looped in an menu.....and the "order" field sets the order of the menu links (name).
I have a form to udate all "order"-rows at the same time but i cant get it to work....heres my form and db script:
echo "<form action='page.php?action=order' method='POST'>";
$sql = "SELECT * FROM `page` ORDER BY `id` DESC";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_object($result))
{
echo "<input type='text' name='order[$row->id]' value='$row->order'>";
}
echo "<input type='submit' value='save'></form>";
in page.php?action=order:
$sql = "SELECT * FROM `page` ORDER BY `id` DESC";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_object($result))
{
$insert = $_POST["order[$row->id]"];
$sql = "UPDATE `page` SET `order` = `$insert` ORDER BY `id` DESC";
mysql_query($sql) or die(mysql_error());
}
When running this i get the following error:
Unknown column '' in 'field list'
What am I doing wrong?
Thanks in advance
Niklas