How to echo out 3 column table

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
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

How to echo out 3 column table

Post by adsegzy »

Hello friends, I need a help. I know now to echo out a 1 column table to display my search result. but i need to echo out my result in a table of about 3 columns to display my catelogue. please what is the syntax for it.

regards
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How to echo out 3 column table

Post by Benjamin »

Code: Select all

<table cellspacing="0">
  <tr>
    <th>1</th>
    <th>2</th>
    <th>3</th>
  </tr>
  <?php foreach ($result as $row): ?>
  <tr>
    <td><?php echo $row['1']; ?></td>
    <td><?php echo $row['2']; ?></td>
    <td><?php echo $row['3']; ?></td>
  </tr>
  <?php endforeach; ?>
</table>
Post Reply