Fixed one little bug, starting $ix at 0 instead of 1. This worked for me up until it tried to do the DB query stuff, since I don't have the DB, but it got past the "not all fields" error.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Inventory Search</title>
</head>
<p><body>
<h3>Search Product Details</h3>
<p>This box allows a user to search by the item(s) description</p>
<form method="post" action="test2.php?go">
Isle: <input type="text" name="name0"> <br />
Column: <input type="text" name="name1"> <br />
R: <input type="text" name="name2"> <br />
Rows: <input type="text" name="name3"> <br />
Quantity: <input type="text" name="name4"> <br />
Partnumber: <input type="text" name="name5"> <br />
Surplus: <input type="text" name="name6"> <br />
Description: <input type="text" name="name7"> <br />
Cost: <input type="text" name="name8"> <br />
Entryorder: <input type="text" name="name9"> <br />
icrr: <input type="text" name="name10"> <br />
irrc: <input type="text" name="name11"> <br />
rowm: <input type="text" name="name12"> <br />
<input type="submit" name="submit" value="Search Inventory">
</form>
<?php
//******** for now turn on all error reportgin:
ini_set('display_errors', 1); // set to 0 for production version
error_reporting(E_ALL);
//*********** let's simplify all those nested if()'s, and use an array instead
//*********** of separate scalar variables:
if (isset($_POST['submit']) && isset($_GET['go'])) {
//connect to the database
$db = mysql_connect("localhost", "root", "") or die('I cannot connect to the database because: ' . mysql_error());
$name = array();
for ($ix = 0; $ix <= 12; $ix++) {
$name[$ix] = (isset($_POST["name$ix"])) ?
mysql_real_escape_string($_POST["name$ix"]) :
false;
}
//********** make sure we got each "name" value from form:
if (count($name) == count(array_filter($name))) {
//-select the database to use
$mydb = mysql_select_db("cambellsales");
//-query the database table
//********** use array elements:
$sql = "
SELECT *
FROM inventory
WHERE Isle LIKE '%" . $name[0] . "%'
AND Col LIKE '%" . $name[1] . "%'
AND R LIKE '%" . $name[2] . "%'
AND Row LIKE '%" . $name[3] . "%'
AND Quantity LIKE '%" . $name[4] . "%'
AND PartNumber LIKE '%" . $name[5] . "%'
AND Surplus LIKE '%" . $name[6] . "%'
AND Description LIKE '%" . $name[7] . "%'
AND Cost LIKE '%" . $name[8] . "%'
AND EntryOrder LIKE '%" . $name[9] . "%'
AND ICRR LIKE '%" . $name[10] . "%'
AND IRRC LIKE '%" . $name[11] . "%'
AND RowM LIKE '%" . $name[12] . "%'"
;
//-run the query against the mysql query function
$result = mysql_query($sql);
//********* debug if it failed:
if($result == false) {
user_error(mysql_error()."<br />\n$sql");
}
// Counts the number of rowes that are returned
echo mysql_num_rows($result);
//-create while loop and loop through result set
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_array($result)) {
echo "<tr>";
echo "<td>" . $row['Isle'] . "</td>";
echo "<td>" . $row['Col'] . "</td>";
echo "<td>" . $row['R'] . "</td>";
echo "<td>" . $row['Row'] . "</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>";
}
}
//******** let user know they left something empty:
else {
echo "<p>ERROR: Not all 'name' fields were entered.</p>";
}
}
?>
</body>
</html>