My code just says couldn't execute query, not sure if thats the main query or the ones for the drop down boxes, any help please I've been looking at this for ages?
echo "<form name='form' action='testing.php' method='get'>\n";
$query = "SELECT * FROM soiltype";
$result = mysql_query($query)
or die ("Couldn't execute query");
while($row = mysql_fetch_array($result)) $soiltype[]=$row;
echo "<SELECT name='x'>";
foreach ($soiltype as $s)
echo "<OPTION>{$s['soiltype']}</OPTION>\n";
echo '</SELECT>';
$query1 = "SELECT * FROM product";
$result1 = mysql_query($query1)
or die ("Couldn't execute query");
while($row1 = mysql_fetch_array($result1)) $surface[]=$row1;
echo "<SELECT name='y'>";
foreach ($surface as $su)
echo "<OPTION>{$su['surface']}</OPTION>";
echo '</SELECT>';
$query2 = "SELECT * FROM product";
$result2 = mysql_query($query2)
or die ("Couldn't execute query");
while($row2 = mysql_fetch_array($result2)) $soillevel[]=$row2;
echo "<SELECT name='z'>";
foreach ($soillevel as $so)
echo "<OPTION>{$so['soillevel']}</OPTION>";
echo '</SELECT>';
echo "<input type='submit' name='Submit' value='Search'>
</form>\n";
// Get the search variable from URL
$var = @$GET['z'] ;
$trimmed = trim($var); //trim whitespace from the stored variable
$var1 = @$GET['y'] ;
$trimmed1 = trim($var1);
$var2 = @$_GET['x'] ;
$trimmed2 = trim($var2);
// rows to return
$limit=10;
// check for a search parameter
if (!isset($var))
{
echo "<p></p>";
exit;
}
// check for a search parameter
if (!isset($var1))
{
echo "<p></p>";
exit;
}
// check for a search parameter
if (!isset($var2))
{
echo "<p></p>";
exit;
}
// Build SQL Query
$query3 = "select product from product,soiltype where product.ID=soiltype.ID AND soiltype like \"%$trimmed%\"
AND surface like \"%$trimmed1%\" AND soillevel like \"%$trimmed2%\"
order by product";
// table and field names for the SQL query
$numresults=mysql_query($query3);
$numrows=mysql_num_rows($numresults);
// s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}
// get results
$query3 .= " limit $s,$limit";
$result3 = mysql_query($query3) or die("Couldn't execute query");
// display what the user searched for
echo "<p><strong>You searched for: "" .$var. """" .$var1. """" .$var2. ""</strong></p>";
// begin to show results set
echo "The best product for you to use is:";
$count = 1 + $s ;
// display the results returned
while ($row3= mysql_fetch_array($result3)) {
$title = $row3["product"];
echo " <strong>$title</strong>" ;
$count++ ;
}
$currPage = (($s/$limit) + 1);
//break before paging
echo "<br />";
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$news=$s+$limit;
echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>";
}
//Code completed by Mitchel Evans
?>