0
  1. Im trying to display a record with a where clause
  2. It has an error "Trying to get property 'num_rows' of non-object"

    '<?php'
    'require_once "connect.php";'
    '$sql = "SELECT No,TimeIssued,Type FROM QueueR WHERE Type='Regular'";'
    '$result = $conn->query($sql);' 
    'if($result->num_rows > 0){'
    'echo "<table class='table table-bordered table-striped'>";'
    'echo "<thead>";'
    'echo "<tr>";'
    'echo "<th>No</th>";'
    'echo "<th>TimeIssued</th>";'
    'echo "</tr>";'
    'echo "</thead>";'
    'echo "<tbody>";'
    'while($row = $result->fetch_assoc()){'
    'echo "<tr>";'
    'echo "<td>" . $row['No'] . "</td>";'
    'echo "<td>" . $row['TimeIssued'] . "</td>";'
    'echo "</tr>";'
    '}'
    'echo "</tbody>";'                            
    'echo "</table>";'
    '$result->free();'
    '} else{'
    'echo "<p class='lead'><em>No records were found.</em></p>";'
    '}'
    '?>'
    

    '''

1 Answers1

0

Check if $conn in the connect.php is connecting fine.

Try testing the query in a mysql client.

Use include("connect.php") instead of require_once "connect.php".