How to print output in colums?

Discussion in 'PHP' started by olddocks, Oct 14, 2007.

  1. #1
    I have been struggling with printing colums. For example i want to pull out results from database and want to display those data in 3 colums by splitting it.

    how to do it in a easy way.
     
    olddocks, Oct 14, 2007 IP
  2. ste.richards

    ste.richards Guest

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The simplest way to do this would be to output the database contents into a HTML table.

    $query = mysql_query("SELECT something FROM somewhere"); ?>

    <table>
    <th> Col 1 </th>
    <th> Col 2 </th>
    <th> Col 3 </th> <?php

    while($r = mysql_fetch_array($query)) { ?>
    <tr>
    <td> <?php echo $r['col1data']; ?> </td>
    <td> <?php echo $r['col2data']; ?> </td>
    <td> <?php echo $r['col3data']; ?> </td>
    </tr> <?php
    } ?>
    </table>

    That should do the job.
     
    ste.richards, Oct 14, 2007 IP
    olddocks likes this.
  3. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #3
    thanks mate :D +rep added
     
    olddocks, Oct 15, 2007 IP