I have the following code:
<table>
<thead>
<tr>
<th>Service</th>
<th>Status</th>
</tr>
</thead>
<?php $result = mysql_query("SELECT Service, Status FROM services WHERE Company='Company 1'");
while ($row = mysql_fetch_array($result)) {
// ^ must be a single '=' !!!!
echo '<tr><td>' . $row["Service"] . '</td>';
echo '<td>' . $row["Status"] . '</td></tr>';
} ?>
</table>
To display multiple rows from a MySQL database in an HTML table. My question is.. how would I determine if there are no rows that match my criteria, and display a message indicating that it is empty?
In my opinion, the best way is a if statement + do/while loop :
You can also use mysql_num_rows function, but keep in mind there is no such function for PDO API and the do/while solution works with any API.
P.S. If you only use the associative part of your array, use mysql_fetch_assoc instead of mysql_fetch_array.