angst
06-08-2007, 07:58 PM
Hello!
having issues with this function, mainly the logic behind it I guess.
I've got a very simple CMS, and order the pages to be displayed on the front end with a TinyInt field in the db.
Function SetPageOrder($numSectionID,$numPageOrder){
// Check Page Order and Increment if needed
$result = mysql_query("SELECT Id,PageOrder FROM pages WHERE ParentID = " . $numSectionID );
while ($row = mysql_fetch_array($result)){
If($numPageOrder == $row['PageOrder'] || $numPageOrder < $row['PageOrder']){
mysql_query( "UPDATE PageOrder SET PageOrder = PageOrder + 1 WHERE Id=" . $row['Id'] );
}
}
}
what i'm trying to do here, is if i create a new page and set the page order to 1 for example, I would like all the other pages in that section to bump up a number. I thought this function would work, but no go.
any ideas would be great,
thanks in advance for your time!
-Ken
having issues with this function, mainly the logic behind it I guess.
I've got a very simple CMS, and order the pages to be displayed on the front end with a TinyInt field in the db.
Function SetPageOrder($numSectionID,$numPageOrder){
// Check Page Order and Increment if needed
$result = mysql_query("SELECT Id,PageOrder FROM pages WHERE ParentID = " . $numSectionID );
while ($row = mysql_fetch_array($result)){
If($numPageOrder == $row['PageOrder'] || $numPageOrder < $row['PageOrder']){
mysql_query( "UPDATE PageOrder SET PageOrder = PageOrder + 1 WHERE Id=" . $row['Id'] );
}
}
}
what i'm trying to do here, is if i create a new page and set the page order to 1 for example, I would like all the other pages in that section to bump up a number. I thought this function would work, but no go.
any ideas would be great,
thanks in advance for your time!
-Ken