Dysan Posted November 9, 2007 Share Posted November 9, 2007 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 More sharing options...
bwochinski Posted November 9, 2007 Share Posted November 9, 2007 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... Link to comment https://forums.phpfreaks.com/topic/76678-display-data-on-next-line-table/#findComment-388220 Share on other sites More sharing options...
Dysan Posted November 9, 2007 Author Share Posted November 9, 2007 Can it be done without the use of span? As span only works on IE? - Doesn't It Link to comment https://forums.phpfreaks.com/topic/76678-display-data-on-next-line-table/#findComment-388226 Share on other sites More sharing options...
AndyB Posted November 10, 2007 Share Posted November 10, 2007 How do I display "Firstname" and "Lastname" in the same column, with "Lastname" on a new line? Perhaps I don't understand the question, but using an html break would do what you want. Link to comment https://forums.phpfreaks.com/topic/76678-display-data-on-next-line-table/#findComment-388276 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.