Page 1 of 1

Simple PHP / Table problem

Posted: Sat Jul 28, 2007 12:11 pm
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>

Re: Simple PHP / Table problem

Posted: Sat Jul 28, 2007 12:28 pm
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.