Jump to content

Display Data on Next Line (Table)


Dysan

Recommended Posts

Hi.

 

The following code, displays each record in an individual column.

How do I display "Firstname" and "Lastname" in the same column, with "Lastname" on a new line?

 

$result = mysql_query("SELECT * FROM People");

echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>";
$record = 1;
while($row = mysql_fetch_array($result))
{
  echo "<tr>";
  echo "<td>" . $record++ . ") " . $row['Firstname'] . "\n</td>";
  echo "<td>" . $row['Lastname'] . "</td>";
  echo "<td>" . $row['Age'] . "</td>";
  echo "</tr>";
}
echo "</table>";

Link to comment
https://forums.phpfreaks.com/topic/76678-display-data-on-next-line-table/
Share on other sites

echo "<tr>";
echo "<td>
<span>" . $record++ . ") </span>
<span>
<div>" . $row['Firstname'] . "</div>
<div>" . $row['Lastname'] . "</div>
</span>
</td>";
echo "<td>" . $row['Age'] . "</td>";
echo "</tr>";

 

didn't test the layout, but I think that'll make it work nicely...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.