Hello,
I hope you you guys/girls/gentlemen/ladies can help me because i cant figure out what i am doing wrong.
I need to make a forum for a school project in php and the thing i am trying to do is make a php script that shows the main categories and the sub categories, the sub categories work like i want them to, but the main categories stop after 3 for loops.
I include this in my index.php so the background of the body tag (css) should also be taken over but it stops when the table begins (when i take away the code for showing the sub categories, the background displays properly and that is again a mystery for me.)
Here is the database that i am using
[table][tr]
[td]AUTO increment[/td] [td]CAN be NULL[/td][/tr]
[tr]
[td]cat_id[/td] [td]parent_id[/td] [td]cat_name[/td] [td]cat_dis[/td][/tr]
[tr]
[td]1[/td] [td]NULL[/td] [td]test1[/td] [td]test1[/td][/tr]
[tr]
[td]2[/td] [td]NULL[/td] [td]test2[/td] [td]test2[/td][/tr]
[tr]
[td]4[/td] [td]2[/td] [td]hoi2[/td] [td]hoi2[/td][/tr]
[tr]
[td]9[/td] [td]NULL[/td] [td]oke[/td] [td] laatste[/td][/tr][/table]
and here is the piece of code that actually matters (include works)
[php]
<?php include'includes/connect.php'; $table = "category"; $result = mysql_query("select * from ".$table." WHERE parent_id IS NULL") or die ( mysql_error()); // works $count_row = mysql_num_rows($result) or die ( mysql_error()); // it got 4 rows and that was what was in the database at the time so this works echo''; echo' | '; echo' | Name | ';
echo'Discription | ';
// still need h refs
if(isset($_SESSION['admin'])){echo'Edit | ';} if(isset($_SESSION['admin'])){echo'Delete | ';} if ($count_row > 0) // works also { //doesnt it will only go 3x whatever the row count is for ($i = 0; $i < $count_row ; $i++) { $c1 = mysql_result($result, $i, "cat_id"); $c3 = mysql_result($result, $i, "cat_name"); $c4 = mysql_result($result, $i, "cat_dis"); echo "
---|---|---|---|---|---|
| ";
echo ""; echo " | ".$c3." | " ;
echo "".$c4." | " ; echo "||
"; echo " | ".$sc3." | ";
echo "".$sc4." | "; echo "|||
Any suggestions what i could do differently are also welcome,
Jermey