hi. im going to try and explain this as clearly as possible...im in a hurry for a solution :/
so i need to create a shopping list application that allows a user to create a list, populate it with categories (frozen food, fruit, electrical etc) and then populate categories with items (burgers, apples, DVD's) they need to be able to add, edit and delete lists, items and categories aswell as be able to order them individually (for example move frozen category up or down the list to any position...same for items in categories).
so i created a database...i have 3 tables:
List table (listid, listname, listorder)
Category table (catid, listid, catname, catorder)
item table (itemid, catid, itemname, itemorder)
i got it to create, edit and delete lists...but when i view a list to see the categories and items in that list i cant get it to display properly.
i used this code:
$sql=mysql_query("SELECT items.itemname, cat.category FROM items,cat WHERE cat.catid=items.catid");
while($res=mysql_fetch_array($sql))
{
echo $res['category'] . "<br>";
echo $res['itemname'] . "<br>";
}
however it displays the results as follows:
frozen
chips
frozen
burgers
fruit & veg
apples
fruit & veg
potatoes
what i need is for it to display the category name only once...then each item under that correct category..then display the next category and its respected items etc etc.
like this:
Frozen
burgers
chips
fruit & veg
apples
potatoes
that is my main problem..the only other thing i would like to ask is how do i order things? and i dont just mean ascending or descending..i mean individual items...someone told me to create an order field in each table..but i dont know what to do with them.
please help anybody?
im not great with php any examples would be greatly appreciated as most terminology goes straight over my head 🙁
thanks in advance