08-11-2008, 06:33 PM
|
#2 (permalink)
|
|
The Contributor
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
|
It looks like you will need to reset the record pointer for $sidePanelPages like so:
php Code:
<?phptry { // 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...
|
|
|
|