Put a table in a php with the first row

74 Views Asked by At

I am trying to put in a php page with a table and I can't see the first row and I don't know why...

My code is:

$search= "SELECT code_resource FROM queue ORDER BY turn ASC";  
$result= $db->query($search);

$queue = mysqli_fetch_assoc($result);
$code = $queue['code_resource'];

if($result->num_rows != 0)
{       
    echo "<table align=center border=2>";

    while($row=mysqli_fetch_array($result, MYSQLI_ASSOC))
    {
        echo "<tr>";
        $code= $fila['code_resource'];
        $search2= "SELECT * from resources WHERE code=$code";
        $result2= $db->query($search2);     

        $row2= mysqli_fetch_array($result2, MYSQLI_ASSOC);
        $place= $row2['place'];

        echo "<td>".$code."</td>";                                          
        echo "<td>".$place."</td>";

    }
    echo "</table>";

mysqli_free_result($result);
mysqli_free_result($result2);
mysqli_close($db);

I only can see the rest of rows, but I can't see the first row, any idea?

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

You have, on line 4:

$queue = mysqli_fetch_assoc($result);

before the loop. That is getting the first row and you are never using it. Delete it and everything should work.