views:

36

answers:

1

I have a database to keep track of the services clients have. But need to be able to find all the services (on different rows) and display them in an HTML table.

i.e.

Service     Company         Status
-------------------------------------
Service 1   Company 1       Complete
Service 2   Company 2       Pending
Service 3   Company 1       Complete

I need to extract the service and status for each entry for Company 1 and display it in an HTML table. How is this done?

+1  A: 

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>
Time Machine