I am teaching myself PHP and MySQL, and I am trying to retrieve some information from my database and put it into a table.
So far only the table column headers are showing up, and no information is showing up for each column. It is also taking ages for the PHP file to display.
Please can you point out the problem with my code.
<?php
mysql_connect("localhost",$username,$password);
mysql_select_db($dbname) or die("Unable to select Database");
$query = "SELECT * FROM table_1";
$result = mysql_query($query);
$numcount = mysql_num_rows($result);
echo "<h2>$numcount rows in table_1.</h2>";
mysql_close();
?>
<table border="0" cellspacing="4" cellpadding="2">
<tr>
<th><font face="Futura">Type |</font></th>
<th><font face="Futura">Name |</font></th>
<th><font face="Futura">Street |</font></th>
<th><font face="Futura">Address1 |</font></th>
<th><font face="Futura">Address2 |</font></th>
<th><font face="Futura">Town |</font></th>
<th><font face="Futura">County |</font></th>
<th><font face="Futura">Postcode |</font></th>
<th><font face="Futura">Number |</font></th>
<th><font face="Futura">Latitude,Longitude</font></th>
</tr>
<?php
$i=0;
while ($i < 843) {
$type = mysql_result($result,$i,"type");
$name = mysql_result($result,$i,"name");
$street = mysql_result($result,$i,"street");
$addr1 = mysql_result($result,$im,"address1");
$addr2 = mysql_result($result,$im,"address2");
$town = mysql_result($result,$im,"town");
$county = mysql_result($result,$im,"county");
$postcode = mysql_result($result,$im,"postcode");
$number = mysql_result($result,$im,"number");
$latlong = mysql_result($result,$im,"latlong");
}
?>
<tr>
<td><font face="Futura"><?php echo $type;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $name;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $street;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $addr1;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $addr2;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $town;?></font></td>
</tr>
<?php
$i++;
?>
<?
echo "</table>";
?>
</body>
</html>