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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.