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>"; Quote Link to comment 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... Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.