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); ?> Quote Link to comment 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']. ")"; Quote Link to comment Share on other sites More sharing options...
Dysan Posted November 10, 2007 Author Share Posted November 10, 2007 Can you give me an example? Quote Link to comment 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. 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.