For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > August 2004 > Dynamic menus,MySQL queries and display sorting.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Dynamic menus,MySQL queries and display sorting.
fyrfli

2004-05-14, 10:30 pm

Hello there.

I have this piece of code which is supposed to get the menu and
sub-menu items and display them in order. It is the same code for
all menu items. The problem is that the sub-menu items all display
under the first menu item all the time, no matter what. Anyone have
any clues/suggestions?

--------

<table>
<?php
print ("<tr><td><a
href='index.php'>Home</a></td></tr>");
require 'connect.php';
query1 = "select page_name, menu_sh_desc from menuz";
query2 = "select page_name, prose_sh_desc from
muzingz";
result1 = mysql_query(query1) or
die("Query failed : " . mysql_error() .
"n");
result2 = mysql_query(query2) or
die("Query failed : " .
mysql_error() .
"n");
while (line1 =
mysql_fetch_array(result1))
{

print ("<tr><td><a
href=line1['page_name']>line1['menu_sh_desc']</a></td></tr>");

if
(line1->menu_sh_desc = "Muzings")
{
while (line2 =
mysql_fetch_array(result2))
{
print ("<tr><td
align='center'><a
href=line2['page_name']>line2['prose_sh_desc']</a></td></tr>");
};

};
};
mysql_free_result( result1 );
mysql_free_result( result2 );
?>

</table>

--------



----------------------------------------
The post
originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums


Barand

2004-08-18, 3:57 pm

Do you have a field in muzingz to indicate which record in menuz is
the parent menu?

If so you need to do query2 inside the the outer while loop, selecting
just those muzingz which belong to each menuz

Barand

http://members.aol.com/barryaandrew...agridguide.html easy
data tables - and more

----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com