Jump to content

HELP WITH Query Please


jonnypixel

Recommended Posts

Hi all,  ( I have attached a Jpeg Screen grab for all those who are visual and couldn't be bothered reading my babble )

 

Just asking someone to please tell me why my code is not working. ( I have placed the code directly under my brief explanation  )

 

I just want the Query to display the data on every menu item - ATM its only displaying data on the very last menu - and does this every time i add a new menu and submenu items to it.

 

I have 3 fields that hold the structure inside a MYSQL row.

 

cat_name                : Accounts

subcat1_name        : Invoices

subcat2_name        : Vendors, Buyers, Templates.

 

I have a menu i made with Jquery, which collects the data using 2 querys.

 

One MYSQL QUERY  displays subcat1_name based on the cat_name ( And this loops giving me horizontal tabs )

 

The Second MYSQL QUERY displays subcat2_name  based on subcat1_name Name ( And so this loops and displays them in the slide down menu )

 

So...

If I Rollover the Top Level Tabs , It seems that only the last Tab in the Menu works and the other ( which have sub menu items ) dont display.

 

I think i have my loop query just getting the last entry's to the TABLE but dont know how to fix this.

 

 


<ul class="menu" id="menu"> 

<?php 

$place= $_GET['place'];  // This is just getting the table extension based on the page.

$result = mysql_query("SELECT * FROM myTable_".$place." GROUP BY subcat1_name ORDER by id") or die(mysql_error()); 
while($row=mysql_fetch_assoc($result)) {  

$subcat1  = $row['subcat1_name']; 
?> 

<li><a href="#"><?php echo $subcat1 ; ?></a>    // Top level menu items

<?php } ?>

<ul>

<?php 
$result = mysql_query("SELECT * FROM myTable_".$place." WHERE subcat1_name='$subcat1' GROUP BY subcat2_name ORDER by id") or die(mysql_error()); 
while($row=mysql_fetch_assoc($result)) {  

$subcat2  = $row['subcat2_name']; 

?> 

<li><a href="#"><?php echo $subcat2 ; ?></a>  // Submenu Level Menu items 

<?php } ?>

</li>
</ul>
</li>
</ul>  

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/205307-help-with-query-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.