dc_jt Posted November 8, 2006 Share Posted November 8, 2006 I have a cms which displays all categories with up and down arrows next to them determining what position they will be shown on the webpage. I need to have an option where i can make one listing static at the top (In other words, always position 1)I have done the up and down arrows like this:[quote]public function MoveUp($iAwardId) { $sSql = "SELECT ordering FROM $this->sTableName WHERE $this->sPrimaryKey = '$iAwardId' "; $rMoveUp = mysql_query($sSql, $this->oDb->GetConnection()); $iOrder = (int) @mysql_result($rMoveUp, 0, 'ordering'); $sSql = "SELECT $this->sPrimaryKey, ordering FROM $this->sTableName WHERE ordering > '$iOrder' ORDER BY ordering ASC LIMIT 1 "; $rMoveUp = mysql_query($sSql, $this->oDb->GetConnection()); $iAboveAwardId = (int) @mysql_result($rMoveUp, 0, $this->sPrimaryKey); $iAboveOrder = (int) @mysql_result($rMoveUp, 0, 'ordering'); if($iAboveAwardId == 0) { return false; } $sSql = "UPDATE $this->sTableName SET ordering = '$iAboveOrder' WHERE $this->sPrimaryKey = '$iAwardId' "; mysql_query($sSql, $this->oDb->GetConnection()); $sSql = "UPDATE $this->sTableName SET ordering = '$iOrder' WHERE $this->sPrimaryKey = '$iAboveAwardId' "; //die($sSql); mysql_query($sSql, $this->oDb->GetConnection()); return true; } public function MoveDown($iAwardId) { $sSql = "SELECT ordering FROM $this->sTableName WHERE $this->sPrimaryKey = '$iAwardId' "; $rMoveDown = mysql_query($sSql, $this->oDb->GetConnection()); $iOrder = (int) @mysql_result($rMoveDown, 0, 'ordering'); $sSql = "SELECT $this->sPrimaryKey, ordering FROM $this->sTableName WHERE ordering < '$iOrder' ORDER BY ordering DESC LIMIT 1 "; //die($sSql); $rMoveDown = mysql_query($sSql, $this->oDb->GetConnection()); $iBelowAwardId = (int) @mysql_result($rMoveDown, 0, $this->sPrimaryKey); $iBelowOrder = (int) @mysql_result($rMoveDown, 0, 'ordering'); if($iBelowAwardId == 0) { return false; }[/quote]Any idea how I do the static one?Thanks Link to comment https://forums.phpfreaks.com/topic/26555-cms-positioning-making-something-static-at-the-top-position-1/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.