Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><br /> I found the solution for my question, I am posting here so if someone looking for something similar can check it out.<br /> Here is the code to update table.<br /> In the example table name massage. the variable <code>$old_position</code> is a select statement to check using where clause by id. the variable <code>$position</code> comes from form and relates to a new position.</p> <pre><code>if($old_position &gt; $position) { mysql_query("UPDATE `massage` SET position = position + 1 WHERE position BETWEEN '$position' AND '$old_position'"); } if($old_position &lt; $position) { mysql_query("UPDATE `massage` SET position = position - 1 WHERE position BETWEEN '$old_position' AND '$position'"); } mysql_query("UPDATE `massage` SET position = '$position', name = '$name', visible = '$visible', content = '$content', date = '$date' WHERE id = '$id'"); </code></pre> <p>Here is for delete a row and updated the position</p> <pre><code>mysql_query("UPDATE `massage` SET position = position - 1 WHERE position &gt; '$position'"); mysql_query("DELETE FROM `massage` WHERE id = '$id' LIMIT 1"); </code></pre> <p>And finally here is the code to insert</p> <pre><code>mysql_query("UPDATE `massage` SET position = position + 1 WHERE position &gt;= '$position'"); mysql_query("INSERT INTO `massage` (position, name, visible, content, date) VALUES ('{$position}', '{$name}', '{$visible}', '{$content}', '{$date}')"); </code></pre> <p>Thanks to everyone took something to help around.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload