lilwing Posted July 16, 2008 Share Posted July 16, 2008 I sure hope someone can help with this problem, I have been up all night trying to figure it out. Basically, I have a table called hyperlinks, with the columns: HREF, Name, Category, PrimaryCategory, and LinkOrder. I am trying to use a database for holding the links in the navigation bar. HREF is the source of the URL, Name goes between the a tags, category is either primary or secondary (primary would be the main navigation, and secondary would be the subnavigation... kind of like a dropdown) PrimaryCategory is the name of the primary category which a given set of secondary links falls under... it is null for all entries with 'primary' in the Category field. Link order is an integer entry, used to order the links. With some frustration, and help from the boards, I have finally gotten the primary navigation links to show. What I haven't been able to do, is get the secondary links to appear under the proper primary navigation link. For example, say I want the list to function something like this: <ul> <li><a href="#">home</a> <li><a href="#">what should be under home</a> </li> </ul> So I want it to be something like this: Where PrimaryCategory = PrimaryName; <ul> <li><a href="PrimaryHREF"">PrimaryName</a> <a href="SecondaryHREF">SecondaryName</a> </li> </ul> I've wasted quite a bit of time trying to figure this out. However it is very important. I hope you can help. Here is the source: <?php $query = mysql_query('SELECT * FROM hyperlinks ORDER BY LinkOrder ASC') or die(mysql_error()); while($row = mysql_fetch_array($query)) { while($row[Category] = 'primary') { $primaryName = $row[Name]; $primaryHREF = $row [hrEF]; $primaryCategory = $row['PrimaryCategory']; $secondaryName = $row['Name']; $secondaryHREF = $row['HREF']; echo ('<li class="off"><a href="http://www.sfisk12.org/index.php?pageid='.$primaryHREF.'">'.$primaryName.'</a>'); echo ('<ul>'); echo ('<li><a href="'.$secondaryHREF.'"></a>'.$secondaryName.'</li>'); echo('</ul>'); echo ('</li>'); ?> Link to comment https://forums.phpfreaks.com/topic/115033-solved-oh-craps-need-help-echoing-mysql-data-into-xhtml-list/ Share on other sites More sharing options...
lilwing Posted July 16, 2008 Author Share Posted July 16, 2008 bump still no luck.. Link to comment https://forums.phpfreaks.com/topic/115033-solved-oh-craps-need-help-echoing-mysql-data-into-xhtml-list/#findComment-591580 Share on other sites More sharing options...
lilwing Posted July 17, 2008 Author Share Posted July 17, 2008 this is what i have so far. not sure where i am making a mistake. any help? <?php $query = mysql_query('SELECT * FROM hyperlinks WHERE Category="primary" ORDER BY LinkOrder ASC') or die(mysql_error()); $row = mysql_fetch_array($query); $primaryName = $row['Name']; $primaryHREF = $row ['HREF']; echo ('<li class="off"><a href="'.$primaryHREF.'">'.$primaryName.'</a>'); $query2 = mysql_query('SELECT * FROM hyperlinks WHERE Category="secondary" AND PrimaryCategory="$primaryName" ORDER BY LinkOrder ASC') or die(mysql_error()); $row = mysql_fetch_array($query2); $secondaryName = $row2['Name']; $secondaryHREF = $row2['HREF']; $primaryCategory = $row2['PrimaryCategory']; echo ('<ul>'); echo ('<li><a href="'.$secondaryHREF.'"></a>'.$secondaryName.'</li>'); echo('</ul>'); echo ('</li>'); ?> Link to comment https://forums.phpfreaks.com/topic/115033-solved-oh-craps-need-help-echoing-mysql-data-into-xhtml-list/#findComment-592547 Share on other sites More sharing options...
lilwing Posted July 17, 2008 Author Share Posted July 17, 2008 Well thanks for yourhelp guys. For anyone who has trouble with this dynamic menu sort of thing, check this out: http://www.finalwebsites.com/tutorials/dynamic-navigation-list.php Link to comment https://forums.phpfreaks.com/topic/115033-solved-oh-craps-need-help-echoing-mysql-data-into-xhtml-list/#findComment-592561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.