Dysan Posted November 10, 2007 Share Posted November 10, 2007 Hi, Using the following code, how do I create a one column table, with "Firstname, Lastname & Sex" as the heading. Also, how do I display the row data (i.e Firstname etc) using the following format?: $record) $Firstname $Lastname ($Sex) <link rel="stylesheet" type="text/css" href="Index.css" /> <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die(mysql_error()); } mysql_select_db("WB", $con); $result = mysql_query("SELECT * FROM Birds"); //This should be the column heading. echo "Firstname, Lastname & Sex"; $record = 1; while($row = mysql_fetch_array($result)) { //Display all this on each row. echo $record++; echo $row['Firstname']; echo $row['Lastname']; echo $row['Sex']; } mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/76698-create-a-one-column-table/ Share on other sites More sharing options...
AndyB Posted November 10, 2007 Share Posted November 10, 2007 It's all about html and concatenation... echo $record++. ") "; echo $row['Firstname']. "<br/>"; echo $row['Lastname']. " (; echo $row['Sex']. ")"; Link to comment https://forums.phpfreaks.com/topic/76698-create-a-one-column-table/#findComment-388286 Share on other sites More sharing options...
Dysan Posted November 10, 2007 Author Share Posted November 10, 2007 Can you give me an example? Link to comment https://forums.phpfreaks.com/topic/76698-create-a-one-column-table/#findComment-388289 Share on other sites More sharing options...
AndyB Posted November 10, 2007 Share Posted November 10, 2007 Can you give me an example? Sure. Read the code I posted. Link to comment https://forums.phpfreaks.com/topic/76698-create-a-one-column-table/#findComment-388712 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.