-3

If the num_row is > 0 the aMsg2 should be echoing but it doesnt even when num_row is > 0. Whats wrong? UPDATE: whole code didnt fit into the post? xD

<?php
    $result = mysqli_query($con, "SELECT u.* FROM users AS u JOIN (SELECT visitorid FROM visitors AS v WHERE v.userid = $userid ORDER BY last_visit DESC LIMIT 6) AS v1 ON u.user_id = v1.visitorid");
    ?>
    <table style="width:100%">

    <?php while($row = mysqli_fetch_array($result))
    {

    $user = $row['user'];

      $res=mysqli_query($con, "SELECT * FROM favorite WHERE favorite='$user' AND l_user='$currentuser'");
      $num_rows = mysqli_num_rows($res);

      if($num_rows > 0){
        $aMsg2 = "Works!";
      }else{
        $aMsg2 = "";
      }
     ?>
        <tr >
          <td><?php echo $row['username']; ?></td>
       </tr>
          <?php
        }
        echo $aMsg2; //doesnt work
        ?>
    </table>
anon
  • 237
  • 2
  • 11

1 Answers1

0

Change from

$num_rows = mysqli_num_rows($result);
if($num_rows2 > 0){

Into

$num_rows = mysqli_num_rows($res);
if($num_rows > 0){
Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50