Hey I am very new to php. I have been trying to get this php script to return a simple 'SELECT * FROM inventory' statement however I am having a problem. When I test the page I get 0 errors however it doesnt put any information in the table's cells that were created. My code is the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTDxhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Campbell Sales</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<h1>Campbell Sales</h1>
<?php
// Connect and select a database
// mysql_connect("localhost", "root", "");
// mysql_select_db("cambellsales");
$con = mysql_connect("", "root", "", "cambellsales");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("cambellsales", $con);
//Run a query
$result = mysql_query("SELECT * FROM inventory WHERE partNumber='606 ZZ'") or die("Query failed with error: ".mysql_error());
echo "<table border='1' cellpadding='8' cellspacing='3'
summary=\"Table holds Cambell inventory information\">
<tr>
<th>isle</th>
<th>col</th>
<th>r</th>
<th>rows</th>
<th>quantity</th>
<th>partnumber</th>
<th>surplus</th>
<th>description</th>
<th>cost</th>
<th>entryorder</th>
<th>icrr</th>
<th>irrc</th>
<th>rowm</th>
</tr>";
// Loop through all table rows
while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td>" . $row['isle'] . "</td>";
echo "<td>" . $row['col'] . "</td>";
echo "<td>" . $row['r'] . "</td>";
echo "<td>" . $row['rows'] . "</td>";
echo "<td>" . $row['quantity'] . "</td>";
echo "<td>" . $row['partnumber'] . "</td>";
echo "<td>" . $row['surplus'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['cost'] . "</td>";
echo "<td>" . $row['entryorder'] . "</td>";
echo "<td>" . $row['icrr'] . "</td>";
echo "<td>" . $row['irrc'] . "</td>";
echo "<td>" . $row['rowm'] . "</td>";
echo "</tr>";
}
// Free result memory and close database connection
mysql_free_result($result);
mysql_close($con);
?>
</table>
</body>
</html>