# Changing display order of db content

**URL:** <https://forum.kirupa.com/t/changing-display-order-of-db-content/199836>\
**Category:** Uncategorized\
**Created:** [September 6, 2006, 2:36pm UTC](https://forum.kirupa.com/t/changing-display-order-of-db-content/199836 "2006-09-06T14:36:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul\_ferrie](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@paul\_ferrie](https://forum.kirupa.com/u/paul_ferrie)\
**Post date:** [September 6, 2006, 2:36pm UTC](https://forum.kirupa.com/t/changing-display-order-of-db-content/199836/1 "2006-09-06T14:36:04Z")

</div>

Hi guys,  
Been tinkering about all afternoon with this and i still cant get it to work ☹

```php

$newcurrorder = $_POST['newcurrorder'];
$currorder = $_POST['currorder'];
if (isset($newcurrorder)) { 
 $sequenceOKlessthanid = $newcurrorder - 1; 
 $sequenceOKgreaterthanid = $currorder + 1; 
 $resequencedid = $newcurrorder; 
 $sequenceSORTBYcurrorder = "DESC";
 if ($newcurrorder > $currorder) { 
  $sequenceOKlessthanid = $currorder-1; 
  $sequenceOKgreaterthanid = $newcurrorder; 
  $resequencedid -= 1; 
  $sequenceSORTBYcurrorder = "ASC"; 
 
 } 
 $query = "SELECT * FROM models WHERE currorder > $sequenceOKlessthanid AND currorder < $sequenceOKgreaterthanid ORDER BY currorder $sequenceSORTBYcurrorder"; 
 $result = mysql_query ($query) or die ("<p><b>ERROR!!!</b></p><BR>".$query."<BR>"); 
 $j=0; 
 while ($rows = mysql_fetch_object($result)) { 
  $contentid = $rows->model_id; 
  $updateset = $resequencedid; 
  if ($j!= 0) {  
   $currorder = ($rows->currorder)+1; 
   if ($sequenceSORTBYcurrorder == "ASC") {
    $currorder-=2; 
    $updateset = $currorder; 
   }   
   $updatequery = "UPDATE models SET currorder='$updateset' WHERE model_id='$contentid'"; 
   $updateresult = mysql_query ($updatequery) or die ("<p><b>ERROR!!!</b></p><BR>".$updatequery."<BR>"); 
   $j+=1; 
  } 
 }
} 

```

Can anyone see if i am missing anything obviuos.  
All i know is that the db is no updated with the new order.  
i feel i am over looking somehing blindingly obviuos.  
Thanks  
Paul
