Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answer from Bill was spot on - but didn't include the PHP code necessary to perform the operation so here is what I ended up with:</p> <pre><code> &lt;?php //if new sort number is less than old sortnum if ($newsortnum &lt; $oldsortnum){ //RUN SEPARATE QUERIES $sql_rename="UPDATE `sourcedocs` SET sort1 = '999' WHERE sort1 =".$oldsortnum." AND category = '".$category."'"; $sql_reorder="UPDATE `sourcedocs` SET sort1 = sort1 +1 WHERE sort1 &gt;= ".$newsortnum." AND sort1 &lt;= ".$oldsortnum." AND category = '".$category."'"; $sql_insert="UPDATE `sourcedocs` SET sort1 =".$newsortnum." WHERE sort1 = '999' AND category = '".$category."'"; } //if new sort number is greater than old sortnum decrement all sortnums greater than new sortnum and decrement sortnums between if ($newsortnum &gt; $oldsortnum){ //RUN SEPARATE QUERIES $sql_rename="UPDATE `sourcedocs` SET sort1 = '999' WHERE sort1 =".$oldsortnum." AND category = '".$category."'"; $sql_reorder="UPDATE `sourcedocs` SET sort1 = sort1 -1 WHERE sort1 &lt;= ".$newsortnum." AND sort1 &gt;= ".$oldsortnum." AND category = '".$category."'"; $sql_insert="UPDATE `sourcedocs` SET sort1 =".$newsortnum." WHERE sort1 = '999' AND category = '".$category."'"; } ?&gt; </code></pre> <p>Long story short - I stopped short of creating a PDO instance for the beginTransaction(); ...a little more messy, but it's working. I may switch to the PDO method but need to move on. Here's a link to the PDO info if you're having similar difficulties:</p> <p><a href="http://www.php.net/manual/en/pdo.construct.php" rel="nofollow">PHP.net - PDO Construct</a><br /> <a href="http://www.php.net/manual/en/pdo.begintransaction.php" rel="nofollow">PHP.net - PDO beginTransaction();</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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