I'm getting close, but still no gold ring. Been trying to set up a expandable menu for my articles directory (which contains the title, url, category and author information). I've tried several scripts such as yadm.js and ddaccordion.js which work just fine if the li's are hard coded. Just can't seem to get the code right to use query results.
The query returns the correct info, just can't get it to display correctly.
On a static page, the following code displays the query correctly:Code:$query="SELECT url, title FROM articles WHERE category = 'accessibility' ORDER BY title ASC";
However, nothing will display when that code is inserted into the code using the scripts.Code:<?php include("dbinfo.inc.php"); $query="SELECT url,title FROM articles WHERE category = 'accessibility' ORDER BY title ASC"; $result=mysql_query($query)or die(mysql_error()); $num=mysql_numrows($result); $i=0; mysql_close(); while ($i < $num) { $title=mysql_result($result,$i,"title"); $url=mysql_result($result,$i,"url"); ?> <ul class="none"> <li><a href="<?php echo $url ?>"><?php echo $title ?></a></li> </ul></li> <? ++$i; } ?>
For example, this ddaccordion.js script code snippet works just fine:
But when I enter my code, nothing but the headers works:Code:<h2 class="menuheader expandable">Accessibility</h2> <ul class="categoryitems"> <li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C1/">Horizontal CSS Menus</a></li> <li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C2/">Vertical CSS Menus</a></li> <li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C4/">Image CSS</a></li> <li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C6/">Form CSS</a></li> <li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C5/">DIVs and containers</a></li> <li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C7/">Links & Buttons</a></li> <li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C8/">Other</a></li> <li><a href="http://www.dynamicdrive.com/style/csslibrary/all/">Browse All</a></li> </ul>
Code:<h2 class="menuheader expandable">Accessibility</h2> <ul class="categoryitems"> <?php include("dbinfo.inc.php"); $query="SELECT url, title FROM articles WHERE category = 'accessibility' ORDER BY title ASC"; $result=mysql_query($query)or die(mysql_error()); $num=mysql_numrows($result); $i=0; while ($i < $num) { $title=mysql_result($result,$i,"title"); $url=mysql_result($result,$i,"url"); ?> <li><a href="<?php echo $url ?>"><?php echo $title ?></a></li> <? ++$i; } ?> </ul></li>


Reply With Quote
Bookmarks