Page 1 of 1

Formatting php output to table columns

Posted: Tue Oct 19, 2004 8:01 pm
by chriso
I want to output two types of data in a mysql table. Courses that have been added, and courses that have been cancelled. I've stored the data in a mysql table using the following structure:

ID INFO ADDDEL

ID is the primary key
INFO is a varchar column which contains the course information
ADDDEL is either "a" for added or "d" for delete.

I want to output the table in two columns, one for all the "a"s and one for all the "d"s. How do I do that and make the columns come out neat and not broken up? For example:

a d
a d
a
a

Thanks.

Posted: Tue Oct 19, 2004 8:22 pm
by kettle_drum
Something like:

Code: Select all

<table>
   <tr>
      <td width="100">
         Column 1
      </td>
      <td width="100">
         Column 2
      </td>
   </tr>
      <?php
         $result = mysql_query('SELECT * FROM blah');
         while($row = mysql_fetch_assoc($result)){
            echo "<tr><td>".$row['hello']."</td><td>".$row['boo']."</td></tr>";
         }
      ?>
</table>