Jump to content

CMS Positioning - Making something static at the top (position 1)


dc_jt

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.