Jump to content

error_22

Members
  • Posts

    14
  • Joined

  • Last visited

error_22's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. thanks, works perfect.Thank you both so much, i was about to cry lolOnce again, thank you!!
  2. 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>"; }
  3. same thing, nothign happens, but this time its cause $_POST["sortorder_" . $row['id']] doesnt seem to contain any information. I tried to print it but nothing showed up.
  4. justsomeguy: I made the changes, still the same thing. Nnothing happens, nothing at all. No errors or anything, but the values arent being updated.
  5. changed it, same thing as before
  6. 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
  7. you lost me there, what do you mean? :S
  8. 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!
  9. well, nothing works now :)cant even update all rows with the same value :)oh and the quotes are there for security purposes
  10. how would your code look with my information? I dont understand it really :S
  11. Im pretty sure its something with the update query. All rows get the same value, which means that the update query cant manage several different values at the same time.
  12. Oh i didnt know that, thanks a lot!Its not working though lol......all rows get the same value.
  13. 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
  14. I want to update serveral/all rows in one column in my mysql db table. Is that possible and if yes, what does the code look like?Thanks in advanceNiklas
×
×
  • Create New...