sorted now thanks, please delete :)
Echoing out subcategories and all their items
Collapse
X
-
-
few observation about your mysql database.
in the table image some columns are unnecessary and problematic
name, parent these two columns are already exists in the first table. you do not need to repeat it here. Because you already have a unique id referenced from your first table name cat_id. using cat_id you easily can find out name and parent from table 1 if you need.Code:image_id name parent small_img large_img cat_id
If you want to access row value using column name you need to use
mysql_fetch_ass oc istead of mysql_fetch_row. follow the example below:
Getting all the row:Code:$row=mysql_fetch_row($result); echo $row['category_id'];//catgory_id must have to pass as string not as constant. //this is wrong way echo $row[name];//it will make compilation error.
your code can only access one line. but you need to access every row to process.Code:# $Row = mysql_fetch_array($result); //get a row of the result, as an array # while($Row) { //only while there is data in the row # echo " <li><a href='index.php?cat=$Row[category_id]'>$Row[name]</a></li>\n"; # $Row = mysql_fetch_array($result); //get next row of results # }
follow the link link. It will give you some good idea about how to get all the row. There is more. But I am little tired to finish all.
Comment