PHP - Categorizing
Hi,
I'm pretty sure that I am complicating thing for something I'm trying to do. In my database, I have some posts, each with a category field. what I'm trying to do is have a list of categories with each post that falls in that category listed underneath each category. ie: Code: [Select] <h3>Category 1</h3> <ul class="nav1"> <li><a href="#">Title of post with category 1</a></li> <li><a href="#">Title of another post with category 1</a></li> <li><a href="#">Title of 3rd post with category 1</a></li> </ul> <h3>Category 2</h3> <ul class="nav1"> <li><a href="#">Title of post with category 2</a></li> <li><a href="#">Title of another post with category 2</a></li> <li><a href="#">Title of 3rd post with category 2</a></li> </ul> Can someone please tell me what the easiest way to do this is? I've tried different tutorials and methods i could think of, but they overcomplicated things. any help would be appreciated, thank you : ) Similar TutorialsHello! We our creating an admin page to display a list of all the items within a mysql database, these items are within a table called "item". Each item is categorized, these categories are in a table called "category" each category has an ID. There is then a table called "links" which links the items to their category using ID's. We want to display each item by their category with an edit and delete button. We have it so all the items display with the two buttons in no specific order however we are not too sure how to make it so they all display via their category. Here is the code we are currently using: Code: [Select] <?php $itemlist = mysql_query("SELECT item.item_name, item.item_description, item.item_image, item.item_price, item.item_id FROM item ORDER BY item.item_id ASC"); $item_count = 0; ?> <?php while( $row = mysql_fetch_array($itemlist) ){?> <?php if(($row['item.item_name'] == 1) && (isset($item_count) && $item_count < 1)) { ?> <?php $item_count ++; } ?> <li class="title"> <h3><?php echo $row['item_name'];?></h3><br /> <form action="ourworkadmin.php" method="get"> <input type="hidden" name="item_id" value="<?php echo $row['item_id'];?>" /> <input name="edit" value="Edit" type="submit" /> <input name="remove" value="Remove" type="submit" /> </form> </li> <?php } ?> </ul> <!--Close-items_list--> </div> Any help would be appreciated! Thank you!!! |