<?php
$dbHost = "UVCvoldb.db.3892101.hostedresource.com";
$dbUser = "UVCvoldb";
$dbPass = "UVCvol2008";
$dbDatabase = "UVCvoldb";
$Type=($_GET['Type']);
$Brand=($_GET['Brand']);
$Size=($_GET['Size']);
$Price=($_GET['Price']);
$Model=($_GET['Model']);
$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
if ( (strlen($Type) > 0) && (strlen($Brand) > 0 ) && (strlen($Size) > 0 ) && (strlen($Price) > 0 ) )
{
$sql= "select * from PRODUCTS where Type="$Type" and Brand="$Brand" and Size="$Size" and Price="$Price" order by ProductID");
}
elseif ( (strlen($Type) > 0) && (strlen($Brand) > 0 ) && (strlen($Size) > 0 ) )
{
$sql= "select * from PRODUCTS where Type="$Type" and Brand="$Brand" and Size="$Size" order by ProductID");
}
elseif ( (strlen($Type) > 0) && (strlen($Brand) > 0 ) )
{
$sql= "select * from PRODUCTS where Type="$Type" and Brand="$Brand" order by ProductID");
}
elseif ( (strlen($Type) > 0) )
{
$sql= "select * from PRODUCTS where Type="$Type" order by ProductID");
}
elseif ( (strlen($Brand) > 0) )
{
$sql= "select * from PRODUCTS where Brand="$Brand" order by ProductID");
}
elseif ( (strlen($Size) > 0) )
{
$sql= "select * from PRODUCTS where Size="$Size" order by ProductID ");
}
elseif ( (strlen($Price) > 0) )
{
$sql= "select * from PRODUCTS where Price="$Price" order by ProductID");
}
elseif ( (strlen($Model) > 0) )
{
$sql= "select * from PRODUCTS where Model="$Model" order by ProductID");
}
else
{
$sql= "select * from PRODUCTS";
}
$result=mysql_query("$sql");
//filter table start
echo <<<END
<form action="products.php?Category=TV" meathod="GET">
<input type="hidden" value="TV" Name="Category">
<table width="969" border="1">
<tr>
<td>Type</td>
<td><select name="Type"><option selected="selected" value="">None</option>
<option Value="Flat Screen Plasma">Flat Screen Plasma</option>
<option Value="Flat Screen LCD"> Flat Screen LCD</option>
</select>
</td>
<td>Brand</td>
<td><select name="Brand"><option selected="selected" value="">None</option>
<option Value="Sony">Sony</option>
<option Value="LG"> LG</option>
</select>
</td>
<td>Size</td>
<td><select name="Size"><option selected="selected" value="">None</option>
<option Value="26">26</option>
<option Value="34"> 34</option>
</select>
</td>
<td>Price</td>
<td><select name="Price"><option selected="selected" value="">None</option>
<option Value="$200-$300">$200-$300</option>
<option Value="$300-$500"> $300-$500</option>
<option Value="$500-$1500"> $500-$1500</option>
</select>
</td>
<td>Model</td>
<td><input type="text" Name="Model"></td>
<td><input type="Submit" name="submit" value="submit"><input type="reset" name="reset" value="Clear"></td>
</tr>
</table>
</form>
END;
// filter table end
while($row = mysql_fetch_array( $result )) {
// displaying products
$Image=$row['Image'];
$Name=$row['Name'];
$ModelNum =$row['Model#'];
$ProductID=$row['ProductID'];
echo "<table width=969>";
echo "<tr><td rowspan=4 width=201>";
echo "<form target=_blank action=viewproduct.php method=post><input type=hidden value=$ProductID name=ProductID />";
echo "<input type=image src=$Image width=201 heigth=144> </form>";
echo "</td><td colspan=2>$Name</td></tr>";
echo "<tr><td>Model#:$ModelNum</td><td>Product ID: $ProductID</td></tr>";
echo "<tr><td colspan=2>If You are interested in this product click (I Want IT Button). REMEMBER only submite once, if you submit more then one time you will be discualified from this product.<form action=addmembid.php method=post><input type=hidden value=$ProductID name=ProductID /><input type=submit name=submit value='I Want It'></form></td></tr>";
echo "</table>";
echo "<hr width=969>";
}
?>
</div>
</center>