Simple PHP / Table problem

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
teege84
Forum Newbie
Posts: 4
Joined: Sat Jul 28, 2007 6:44 am

Simple PHP / Table problem

Post by teege84 »

Hi all,

I think its just me being stupid but I cant get this table right so it only displays one column heading instead of one for each row! Any ideas? I'm assuming its the loop in the wrong place.

Code: Select all

<table width="25%" border="1">
  <tr>
    <td>Surname</td>
    <td>Forename</td>
    <td>Title</td>
  </tr>
  <tr>
    <td> <?echo " $client_surname";?></td>
    <td><?echo "$client_forename";?></td>
    <td><?echo "$client_title";?></td>
<td><?
echo "<a href=\"update.php?id=$id\">Update</a> - <a href=\"delete.php?id=$id\">Delete</a>";
echo "<br><br>";?></td>
<tr>


<?++$i; } } else { echo "The database is empty"; }?>
  
</table>
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Simple PHP / Table problem

Post by superdezign »

teege84 wrote:Any ideas? I'm assuming its the loop in the wrong place.
What loop?
teege84 wrote:

Code: Select all

<table width="25%" border="1">
  <tr>
    <td>Surname</td>
    <td>Forename</td>
    <td>Title</td>
  </tr>
  <tr>
    <td> <?echo " $client_surname";?></td>
    <td><?echo "$client_forename";?></td>
    <td><?echo "$client_title";?></td>
<td><?
echo "<a href="update.php?id=$id">Update</a> - <a href="delete.php?id=$id">Delete</a>";
echo "<br><br>";?></td>
<tr>


<?++$i; } } else { echo "The database is empty"; }?>
  
</table>
Your table is malformed. It only has 3 top rows, and then four rows.


I'm not exactly sure what you're asking, but maybe you'd be interested in the rowspan attribute. You should read the W3C documentation on tables and see the correct way to make them.
Post Reply