I'm trying to display information in a table using a while loop but the table wont display anything if there is only 1 result. If there are more than 1, it will display the results -1. For example, for 5 results it will only display 5.
My query is:
$queryIndexInvoice =
"SELECT *
FROM invoices, clients, users
WHERE invoices.user_id = users.id
AND invoices.client_id = clients.id
AND invoices.estimate = 0
AND invoices.user_id = '$user_id'
AND deleted = 0
ORDER BY invoices.id
DESC LIMIT 5";
$resultIndexInvoice = $connect_db->query($queryIndexInvoice);
$rowIndexInvoice = $resultIndexInvoice->fetch_assoc();
$numIndexInvoice = $resultIndexInvoice->num_rows;
and my table is:
<tbody>
<?php while ($IndexInvoice = $resultIndexInvoice->fetch_assoc()) {?>
<tr class='table_items'>
<td class='item_strip'></td>
<th><input type='checkbox'></th>
<td><?= $IndexEstimate['invoice_id'] ?></td>
<td><?= $dateIndexEstimate ?></td>
<td><?= $IndexEstimate['client_first']?> <?= $IndexEstimate['client_last']?></td>
<td><?= $IndexEstimate['total'] ?></td>
</tr>
<?php
}
?>
</tbody>
Does anyone know what I'm doing wrong?