Hello! I'm trying to do a query from SQL in PHP table. My code is:
<?php
$table = mysqli_query($mysqli,"SELECT song_id, song_name, janr_name, singers.names FROM `songs` INNER JOIN `singers` ON songs.singer_id = singers.singer_id
INNER JOIN `janr_songs` WHERE janr_songs.janr_id = songs.janr_id ");
$row = mysqli_fetch_array($table);
{
echo "<table border='1' >";
echo "<tr><th>№</th><th>Song</th><th>Artist</th><th>Song genre</th><th>Likes</th><th>Dislikes</th><th>LIKED</th><th>DISLIKED</th></tr>";
// echo '<pre>' . print_r($row, true) . '</pre>';
while($row = mysqli_fetch_array($table))
{
?>
<tr>
<th>
<?php echo $row['song_id']; ?>
</th>
<th>
<?php echo $row['song_name']; ?>
</th>
<th>
<?php echo $row['names']; ?>
</th>
<th>
<?php echo $row['janr_name']; ?>
</th>
<th>
<?php echo $row[($query = mysqli_query($mysqli,"SELECT SUM(`likes`) FROM `voting` WHERE `song_id`='".$_POST['song_id']."'"))]; ?>
</th>
<th>
I can't make likes
and dislikes
from Database to be shown in the table row.
I try with that code, but there is a warning: Warning: Illegal offset type in...
<?php echo $row['janr_name']; ?>
</th>
<th>
<?php echo $row[($query = mysqli_query($mysqli,"SELECT SUM(`likes`) FROM `voting` WHERE `song_id`='".$_POST['song_id']."'"))]; ?>
</th>
<th>
What's wrong in this query? :)