mercredi 25 octobre 2017

Can't get specific comment by SELECT and NATURAL JOIN

My problem is no valid entries in comments section. Code is below:

$sql = "
SELECT u.id_u, u.avatar, u.username, u.rank, c.date,c.content, p.id_p, c.id_p, c.id_u
FROM COMMENT c NATURAL JOIN USER u, POST p 
WHERE c.id_p=".$id." AND c.id_u = u.id_u
ORDER BY c.id_c DESC";
    $result = mysqli_query($db,$sql);
    while($row = $result->fetch_array()) {
    echo '
        blah blah, some HTML code..
        echo $row['username'].'</span></a> <span class="text-muted">commented on'.$row['date']'</span>';

And basically code works, but when id of user is more than 3 comment never show up. This making me so angry, because I can't get that comment in any way. screen1 ^ don't worry, about date column, its only temporary solution. So, yeah, I have one column with id_u = 4 (theres another one with id_u in USER's table), and username of 4th user is Moderatorv2. But in this case I can't get even echo with empty username index or something, just like when condition is not true. And one funny




Aucun commentaire:

Enregistrer un commentaire