View Single Post
Old 08-11-2008, 06:33 PM   #2 (permalink)
buggabill
The Contributor
 
buggabill's Avatar
 
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
buggabill is on a distinguished road
Default

It looks like you will need to reset the record pointer for $sidePanelPages like so:

php Code:
<?php

try{
  // Get the categories
  $query = "
    SELECT DISTINCT `category`
    FROM `aaron_eglast`.`egle_post`
    ORDER BY `category` ASC"
;
    $sidePanelCategories = $my->query($query);
    if (mysql_num_rows($sidePanelCategories) == 0)
      throw new exception('Sorry, the side panel could not be brought up because it could not be found. (Error Code: 55302)');
 
   
    // Get SP Pages
    $query = "
    SELECT `category`, `slug`, `title`, `order`
    FROM `aaron_eglast`.`egle_post`
    ORDER BY `category` ASC, `order` ASC"
;
    $sidePanelPages = $my->query($query);
    if (mysql_num_rows($sidePanelPages) == 0)
      throw new exception('Sorry, the side panel could not be brought up because it could not be found. (Error Code: 55303)');
    $b = "";
   
    while ($a = mysql_fetch_array($sidePanelCategories)){
          $b .= '<li class="topLevel"><h3>'.$a['category'].'</h3><ul>';
                while ($c = mysql_fetch_array($sidePanelPages)){
                  if ($c['category'] == $a['category']){
                        $b .= '<li>';
                        if (MOD_REWRITE == true)
                          $b .= '<a href="'. ROOT . '/' . strtolower($c['category']) . '/' . $c['slug'] . '.html' . '">';
                      else
                          $b .= '<a href="'. ROOT . '/arch/' . strtolower($c['category']) . '/index.php' . '?page=' . $c['slug'] . '">';
                            $b .= $c['title'];
                          $b .= '</a></li>';
                    }
                }
               
                // reset pointer
                mysql_data_seek($sidePanelPages, 0);
               
            $b .='</ul></li>';
    }
    if ($b == false)
      throw new exception('There was an error generating the index of the local pages.
          I am sorry, but the pages are unable to be displayed at this moment.'
);
  else
      $sp = $b;
      $smarty->assign('sp',$sp);
}
catch(exception $e){
  $smarty->assign('error',$e->getMessage());
} 
?>

as you may want to start from the beginning of that resultset looking for matching categories, and if the pointer is at the end, it may error out.
__________________
-- Bill
"Why is it drug addicts and computer aficionados are both called users?" -Clifford Stoll

Last edited by buggabill : 08-11-2008 at 06:37 PM. Reason: reword response...
buggabill is offline  
Reply With Quote
The Following User Says Thank You to buggabill For This Useful Post:
Aaron (08-11-2008)