Jump to content

Create a One Column Table


Dysan

Recommended Posts

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

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.