Jump to content

error_22

Members
  • Posts

    14
  • Joined

  • Last visited

Posts posted by error_22

  1. wow it works now!!but only when i changed the $_POST variable to the following:

    echo '<br><br><br><table class="tborder" cellpadding="6" cellspacing="1" border="0" width="80%" align="center"><tr>';	echo "<td colspan='3' class='thead'><b><center>Visa alla sidor</center></b></td></tr><tr>";	echo "<td class='alt2'><b>Titel:</b></td><td class='alt2'><b>Status:</b></td><td class='alt2'><b>Ordning:</b></td></tr>";	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_array($result,MYSQL_ASSOC))	{  echo "<tr><td class='alt2'>{$row['title']}</td>";  echo "<td class='alt2'>";  if ($row['status'] == "true")  { 	 echo "Aktiv";  }  elseif ($row['status'] == "false")  { 	 echo "Inaktiv";  }  echo "</td>";  echo "<td class='alt2'><input type='text' name='sortorder{$row['id']}' value='{$row['sortorder']}'></td></tr>";	}	echo "</table><br><br>";	echo "<center><input type='submit' value='Spara'></form>";

    $sql = "SELECT * FROM `page` ORDER BY `id` DESC";	$result = mysql_query($sql) or die(mysql_error());	while ($row = mysql_fetch_assoc($result))	{ 	 $insert = $_POST["sortorder$row[id]"]; 	  	 $sql = "UPDATE page SET `sortorder` = '{$insert}' WHERE `id` = '{$row['id']}'";  	 mysql_query($sql) or die(mysql_error()); 	 echo "<script type=\"text/javascript\">location.href=\"page.php?show=all\";</script>";	}

  2. what you just corrected only regards what is being displayed in the input text fields. That has nothing to do with the actual update query. Further more, it works as it should, even though it might not be the perfect solution. But what about the problem with the updating? :S

  3. page.php?show=all:

    echo '<br><br><br><table class="tborder" cellpadding="6" cellspacing="1" border="0" width="80%" align="center"><tr>';	echo "<td colspan='3' class='thead'><b><center>Visa alla sidor</center></b></td></tr><tr>";	echo "<td class='alt2'><b>Titel:</b></td><td class='alt2'><b>Status:</b></td><td class='alt2'><b>Ordning:</b></td></tr>";	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_array($result,MYSQL_ASSOC))	{  echo "<tr><td class='alt2'>$row[title]</td>";  echo "<td class='alt2'>";  if ($row['status'] == "true")  {  	echo "Aktiv";  }  elseif ($row['status'] == "false")  {  	echo "Inaktiv";  }  echo "</td>";  echo "<td class='alt2'><input type='text' name='sortorder[{$row['id']}]' value='$row[sortorder]'></td></tr>";	}	echo "</table><br><br>";	echo "<center><input type='submit' value='Spara'></form>";

    page.php?action=order:

    $sql = "SELECT * FROM `page` ORDER BY `id` DESC";	$result = mysql_query($sql) or die(mysql_error());	while ($row = mysql_fetch_array($result,MYSQL_ASSOC))	{  $insert = $_POST["order[{$row['id']}]"];	  $sql = "UPDATE page SET `sortorder` = '$insert' ORDER BY `id` DESC";       mysql_query($sql) or die(mysql_error());  ?><script>location.href='page.php?show=all';</script><?	}

    Thanks!

  4. Thanks for your help guys, still not sure how i would do this though.....Perhaps I should explain my situatuion:Ok so i have a db table named "page" in that table there are several columns, and one of them is named "order".....I have a script for updating the order column but its not working as it should. All rows get the same value, thats the problem. this is my 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());     }

    This does not work as it should, what do I need to change?Thanks in advanceNiklas

×
×
  • Create New...