I found a tutorial thanks to this forum. I went through the tutorial and pretty much figured it out and now I am running into a problem trying ti display the output from my table.
I left t he username and password blank of course.
Here is the error I am getting though when I load the page:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/kbinc/public_html/test/2.php on line 21
Here is my code:
<html>
<head>
<title>Database Training</title>
</head>
<body>
<?
$username=””;
$password=””;
$database=””;
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( “Unable to select database”);
$query=”SELECT * FROM contacts”;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo “<b><center>Database Output</center></b><br><br>”;
$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,”first”);
$last=mysql_result($result,$i,”last”);
$phone=mysql_result($result,$i,”phone”);
$mobile=mysql_result($result,$i,”mobile”);
$fax=mysql_result($result,$i,”fax”);
$email=mysql_result($result,$i,”email”);
$web=mysql_result($result,$i,”web”);
echo “<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>”;
$i++;
}
?>
</body>
</html>
Thanks in advance for the help.