someguy9 Posted June 11, 2007 Share Posted June 11, 2007 Ok here is my code: $gettype = mysql_query("SELECT * from type ORDER BY name asc LIMIT 20"); $getxxxxx = mysql_query("SELECT * from xxxxx ORDER BY name asc"); $typeamount = mysql_num_rows($gettype); echo "We have $typeamount xxxxx Catagories.<br />"; while ($type = mysql_fetch_array($gettype)){ $xxxxx = mysql_fetch_array($getxxxxx); echo ("<h2>".$type[name]."</h2>"); if ($xxxxx[type] == $type[id]){ while ($xxxxx2 = mysql_fetch_array($getxxxxx)){echo "$xxxxx2[name]<br />";}; echo "<br />";} else{echo "None. . .";}; }; ____________________ the part i am having trouble with is the part in bold. I have tried using a 'for' there also. Im trying to get items form my database to list under certain categories they have in type. ??? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/55040-while-help/ Share on other sites More sharing options...
btherl Posted June 11, 2007 Share Posted June 11, 2007 What does your current code do? What did you expect it to do? Link to comment https://forums.phpfreaks.com/topic/55040-while-help/#findComment-272091 Share on other sites More sharing options...
redarrow Posted June 11, 2007 Share Posted June 11, 2007 Please post your current database table ok as we need to use a join ok. plus i dont see the problam your asking ok. Link to comment https://forums.phpfreaks.com/topic/55040-while-help/#findComment-272100 Share on other sites More sharing options...
someguy9 Posted June 11, 2007 Author Share Posted June 11, 2007 ok right now it makes We have 2 XXXX Catagories. Type 1 item 1 Type 2 None. . . Under type 1 i have item 1 and item 2, but it only generates item 1 Link to comment https://forums.phpfreaks.com/topic/55040-while-help/#findComment-272115 Share on other sites More sharing options...
btherl Posted June 11, 2007 Share Posted June 11, 2007 Do you want to fetch xxxxx items for each category returned from the gettype query? Link to comment https://forums.phpfreaks.com/topic/55040-while-help/#findComment-272156 Share on other sites More sharing options...
someguy9 Posted June 11, 2007 Author Share Posted June 11, 2007 I want to basically list TYPE['name'] -ITEM['name'] TYPE['name'] -ITEM['name'] I have a table for the type and a table for the Items. Want the items to while loop show it shows them and I also want the categories (types) to while loop. Like how a message board works with the categories and subcategories Is there a sample anywhere that I can see this? Link to comment https://forums.phpfreaks.com/topic/55040-while-help/#findComment-272158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.