hi i'm stuck with this code, check this out :
my table sql :
video table
id_video id_kategori content1 content2 ....
2 5 ...
3 6 ...
artikel table
id_artikel id_kategori content1 content2 ...
3 5 ...
5 6 ...
kategori table
id_kategori nama_kategori
4 berita
5 videophp
6 videohtml
the source code :
$query = mysqli_query(DB::connect(),"SELECT * FROM `kategori`");
while($row = mysqli_fetch_row($query)){
?>
<ul>
<?php
$jml = mysqli_fetch_row(mysqli_query(DB::connect(),"SELECT (SELECT COUNT(\*) FROM `artikel` WHERE `id_kategori`='$row[0]') as first,(SELECT COUNT(\*) FROM `video` WHERE `id_kategori`='$row[0]') as second FROM dual"))[0];
?>
<li><a href='<?php echo substr($row[1],0,5) == "video" ? "video" : "artikel"; ?>.php?kategori="<?php echo $row[0]; ?>"'><?php echo $row[1].'('.$jml.')'; ?></a></li>
</ul>
<?php
}
?>
it returns :
olahraga(17)
Teknologi(2)
Politik(6)
Berita(2)
video php(0)
video html(0)
everything good except from video table
simple count for just 1 table works just fine
SELECT () FROM video
WHERE id_kategori
= $row[0]
SELECT COUNT() FROM artikel
WHERE id_kategori
= $row[0]
so what's the code wrong from mine, anyone knows? please and thanks