I'm trying to build a php/mysql content management system for my school district. I'm working on the menu system right now.
When you click on a link, it's supposed to list the parent page (the top level of the menu), the current page, and then the child pages (sub pages to the current page).
When I run it, it never returns the correct results. It returns the first child page instead. I can't figure it out. Can anyone help? Here's the code:
//Get the Parent Page info
echo $this->parentPageID;
$sql = "select PageID, PageName, SiteID, ParentPageID, LevelNumber from PageTable where PageID = '$this->parentPageID'";
$this->parentResult = $this->myDb->query($sql);
//Get current page info
$sql = "select PageID, PageName, SiteID, ParentPageID, LevelNumber from PageTable where PageID = '$this->pageNumber'";
$this->currentPageResult = $this->myDb->query($sql);
//Get Page info
$sql = "select PageID, PageName, SiteID, ParentPageID, LevelNumber from PageTable where SiteID = '$this->siteNumber' and ParentPageID = '$this->pageNumber'";
$this->pageResult = $this->myDb->query($sql);
//Print parent page link
echo "Parent Page<br />";
if ($row = $this->myDb->fetchObject($this->parentResult))
{
while ($row = $this->myDb->fetchObject($this->parentResult))
{
echo "<a href = \"index.php?site=$row->SiteID&page=$row->PageID&parentPageID=$row->ParentPageID&level=$row->LevelNumber\" class=\"myMenu\">$row->PageName</a>";
}
}
else
{
echo "No Parent Pages found.";
}
echo "<hr />";