Left Join

Your modifying the code I’m providing, how can this help you?

Where did this come from?

$result = mysql_query("SELECT DISTINCT category FROM products");

First your not using this properly and second it is used to get the column label names in a table…

I was just trying something right before I submitted it and forgot to change it back…I was using the group by statement you provided, I just tried that once, sorry about that…either way wasn’t working, and I still haven’t been able to test the $row you provided, my server has been running slowly, I will try when I get home from work. thanks for understanding

ok, so I figured it out now, thank you. one last thing, it says establish it for all the first submenu, how do I do it for all the further submenus and how would I do the main categories?

<?php $result = mysql_query("SELECT category FROM products GROUP BY category"); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result)) { $items[] = $row[0]; // $row[0] contains one category ie: Main Retail echo $row[0];} } // the submenu is built, one thing left to do! showthegoods($items[0]);// Display all products for the first submenu item... function showthegoods($mycategory) { $result = mysql_query("SELECT * FROM products WHERE category = '$mycategory'"); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result)) { $prod=$row['product']; echo $prod; } } } ?>

which is that where I would have to use a counter that you mentioned for $i?

I got all the products to show the way I would like them too, now it is just a matter of creating the main categories, how do I do this?

Here you go again…

<?php $result = mysql_query("SELECT category FROM products GROUP BY category"); if (mysql_num_rows($result) > 0){ while ($row = mysql_fetch_array($result)){ $items[]=$row[0]; echo ''; } } ?>

Forget about $items, it’s only purpose is to seed the products from the first category in the list. It could be used for other purposes.

Now, start working on your code and stop altering my code. Your not moving forward and frankly I’ve run out of patients. I hope someone else is willing to jump on this merry-go-round, I’m dizzy…

I am sorry if I am not thinking much, I am frustrated and had a hard day at work and have tons on my mind, it is lightening up because I got the subcategories and the sub categories to all display correctly!!!

Sponsor our Newsletter | Privacy Policy | Terms of Service