Formatting php output to table columns

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chriso
Forum Commoner
Posts: 31
Joined: Fri Aug 01, 2003 11:52 am

Formatting php output to table columns

Post 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.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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>
Post Reply