PHP Error When retriewing data from MySQL database


And below is the code for HTML form and PHP and MySQL.
<?php
include "header.php";
if (isset($_POST['submit']))
{
// connect database
$con = mysql_connect("mysql5.000webhost.com", "xxxxx", "xxxxx");
// select database and create table
mysql_select_db("a8995753_db1", $con);
if(!empty($_POST['col1'])) // tutorial for this is here: http://www.webdesignerforum.co.uk/topic/36142-help-with-html-select-drop-down-and-phpmysql/
{
$col1=$_POST['col1'];
}
else
{
$col1=NULL;
}
if(!empty($_POST['col2']))
{
$col2=$_POST['col2'];
}
else
{
$col2=NULL;
}
if(!empty($_POST['col3']))
{
$col3=$_POST['col3'];
}
else
{
$col3=NULL;
}
$result = mysql_query("SELECT $col1, $col2, $col3 FROM Persons");
?>
<table border='1' border-color='#000000'>
<tr>
<?php
if (isset($col1))
{
echo "<th>First Name</th>";
}
if (isset($col2))
{
echo "<th>Last Name</th>";
}
if
(isset($col3))
{
echo "<th>Age</th>";
}
?>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr><td> <?php echo $row['FirstName'] ?> </td> <td> <?php echo $row['LastName'] ?> </td> <td> <?php echo $row['Age'] ?> </td></tr>
<?php
echo "<br />";
}
mysql_close($con);
}
else
{
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<!-- radio buttons names should be the same as column names in the database. -->
<select name = "col1">
<option></option>
<option>FirstName</option>
<option>LastName</option>
<option>Age</option>
</select>
<select name = "col2">
<option></option>
<option>FirstName</option>
<option>LastName</option>
<option>Age</option>
</select>
<select name = "col3">
<option></option>
<option>FirstName</option>
<option>LastName</option>
<option>Age</option>
<input type="submit" name="submit" value="Retrieve/Update Data"></input>
</select></form>
</body>
</html>
<?php
}
?> -
lightswitch -
Thanks
{{ DiscussionBoard.errors[7098318].message }} -
-
KirkMcD -
Thanks
{{ DiscussionBoard.errors[7100550].message }} -
-
chretit -
Thanks
{{ DiscussionBoard.errors[7103854].message }} -
-
SmartWeb -
Thanks
SignatureSmart Web Solutions{{ DiscussionBoard.errors[7126185].message }} -