<?php
// connect to database
include("inc/connect.php");
// include auth and nav
//include("inc/auth.php");
// begin content
//include("inc/nav.php");
// close mysql connection
//mysql_close();
// Check if the form has been submitted.
if (isset($_POST['Submit'])) {
$brandC = $_POST['brandC'];
$typeC = $_POST['typeC'];
$styleC = $_POST['styleC'];
$frameC = $_POST['frameC'];
$groupSetC = $_POST['groupSetC'];
$errors = array(); // Initialize error array.
//If they did not enter a search term we give them an error
if (($brandC == "") AND ($typeC == "") AND ($styleC == "All") AND ($frameC == "") AND ($groupSetC == ""))
{
$errors[] = 'You did not select anything.';
}
//If user only enter Bicycle Brand
elseif (($brandC!="") AND ($typeC=="") AND ($styleC== "All") AND ($frameC== "") AND ($groupSetC== ""))
{
$result = mysql_query("SELECT * FROM cycles WHERE brand='$brandC'");
}
//If user only enter Bicycle Type
elseif (($brandC="") AND ($typeC!=="") AND ($styleC== "All") AND ($frameC== "") AND ($groupSetC== ""))
{
$result = mysql_query("SELECT * FROM cycles WHERE type='$typeC'");
}
//If user only enter Bicycle Frame
elseif (($brandC="") AND ($typeC=="") AND ($styleC == "All") AND ($frameC!== "") AND ($groupSetC== ""))
{
$result = mysql_query("SELECT * FROM cycles WHERE frame='$frameC'");
}
//If user only enter Bicycle GroupSet
elseif (($brandC="") AND ($typeC=="") AND ($styleC== "All") AND ($frameC== "") AND ($groupSetC!== ""))
{
$result = mysql_query("SELECT * FROM cycles WHERE groupSet='$groupSetC'");
}
if (empty($errors)) { // If everything's OK.
echo "<table border=1 style='color:blue'>";
echo "<tr>" ;
echo "<td align=center style='color:red'>CID</td>";
echo "<td align=center style='color:green'>Brand</td>";
echo "<td align=center style='color:red'>Type</td>";
echo "<td align=center style='color:green'>Style</td>";
echo "<td align=center style='color:red'>Model</td>";
echo "<td align=center style='color:green'>Gear No</td>";
echo "<td align=center style='color:red'>Frame</td>";
echo "<td align=center style='color:green'>Group Set</td>";
echo "<td align=center style='color:red'>Price</td>";
echo "<td align=center style='color:green'>Release Date</td>";
echo "</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>" ;
echo "<td align=center>".$row['cycleID'] ."</td>";
echo "<td align=center>".$row['brand']."</td>";
echo "<td align=center>".$row['type']."</td>";
echo "<td align=center>".$row['style']."</td>";
echo "<td align=center>".$row['model'] ."</td>";
echo "<td align=center>".$row['gearNo']."</td>";
echo "<td align=center>".$row['frame']."</td>";
echo "<td align=center>".$row['groupSet']."</td>";
echo "<td align=center>".$row['price']."</td>";
echo "<td align=center>".$row['releaseDate']."</td>";
echo "</tr>";
}
echo "</table>";
exit();
} // End of if (empty($errors)) IF.
mysql_close(); // Close the database connection.
} // End of the main Submit conditional.
if (!empty($errors)) { // Print any error messages.
echo "<h1 style='font-family:Calibri; color:red; text-align:center'>Error!</h1>
<p style='font-family:Calibri; color:#0066FF; text-align:center'>The following <span style='color:red'>error(s)</span> occurred:</p>";
foreach ($errors as $msg) { // Print each error.
echo " <h5 style='font-family:Calibri; color:orange; text-align:center'> - $msg</h5>\n";
}
//echo '</p><p>Please try again.</p>';
echo "<h4 style='font-family:Calibri; color:green; text-align:center'>Please try again....</h4>
<br>
<p style='font-family:Calibri; color:#0066FF; text-align:center'>You will now be returned to the find Cycle page again. <span style='color:red'>Please follow the rules!</span></p>
<META HTTP-EQUIV=\"refresh\" content=\"3; URL=findlist.php\"> ";
}
// Create the form.
?>
Only the 1st and the 2nd condition working rest not working.
error msg:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\cycle\find.php on line 72.