I have a problem with creating multiple sub category with php and mysql where the deeper sub category doesn't get indented. The screenshot is just like:
.
The sealer and wall paint should be indented like hobe.
Ex: 1. painting, 1.1 HOBE, 1.1.1 Sealer, 1.1.2 Wall Paint
I have 3 table:
kategori contain: id_kat, nama_kat
subkategori contain: id_subkat, id_kat, nama_subkat
supersubkategori contain: id_supersub, id_subkat, id_kat, nama_supersub
My code is:
include "config.php";
$sql = mysql_query("SELECT * FROM kategori");
while($data=mysql_fetch_array($sql))
{
echo "<li>".$data['nama_kat'].""; // kategori
$sql2 = mysql_query("SELECT * FROM subkategori WHERE id_kat = '".$data['id_kat']."'"); // sub kategori
if($sql2)
{
echo "<ul>";
while($data2=mysql_fetch_array($sql2))
{
echo "<li>".$data2['nama_sub']."</li>";
}
echo "</ul>";
}
echo "<li>";
$sql3 = mysql_query("SELECT * FROM supersubkategori WHERE id_kat = '".$data['id_kat']."'"); // supersub kategori
if($sql3)
{
echo "<ul>";
while($data3=mysql_fetch_array($sql3))
{
echo "<li><a href='cat.php?kategori=$data3[nama_supersub]'>".$data3['nama_supersub']."</a></li>";
}
echo "</ul>";
}
else
{
echo "</li>";
}
}
?>
I really thankful if someone can help me how solve this problem. Thank you