Hello there!
I'm a noob at this you'll no doubt notice
My problem is, i want to create a feature similar to this one: http://www.jewson.co.uk/en/templates...uestid=2019469
As youll see, you can sort the database by manufacturer, color etc in a way that you can select colour from a particular manufcaturer too.
They use java servlets, i want to use php + mysql.
I have a database in place... i have built a search.htm form with four drop down menus.
This is the results.php page which i know is wrong and doesnt work.
<center>
<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<tr>
<td width="60"><b>Manufacturer</b></td>
<td width="100"><b>Colour</b></td>
<td width="70"><b>Texture</b></td>
<td width="70"><b>Manufacturing Process</b></td>
</tr>
<tr>
<td>
<? $hostname = "l"; // The Thinkhost DB server.
$username = "t"; // The username you created for this database.
$password = "t; // The password you created for the username.
$usertable = "t"; // The name of the table you made.
$dbName = "tt"; // This is the name of the database you made.
MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db( "$dbName") or die( "Unable to select database");
?>
<?
$XX = "No Record Found, to search again please close this window";
$query ="SELECT * FROM bricks WHERE";
if ($Manufacturer != "SelectManufacturer") //The Default select value
{
switch ($Manufacturer) {
case Manufacturer1:
"SELECT * FROM mytable
WHERE Manufacturer='Manufacturer1'";
case Manufacturer2:
"SELECT * FROM mytable
WHERE Manufacturer='Manufacturer2'";
break;
case Manufacturer3:
"SELECT * FROM mytable
WHERE Manufacturer='Manufacturer3'";
break;
}
}
?>
$variable1=$row["Manufacturer"];
$variable2=$row["Colour"];
$variable3=$row["Texture"];
$variable4=$row["Manufacturing Process"];
print ("<tr>");
print ("<td>$variable1</td>");
print ("<td>$variable2</td>");
print ("<td>$variable3</td>");
print ("<td>$variable4</td>");
print ("</tr>");
}
if (!$variable1)
{
print ("$XX");
}
?>
And this is my Search.htm page
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<form method="POST" action="/results.php" target="_blank">
<p><select size="1" name="Select Manufacturer">
<option value="Manufacturer1">Manufacturer1</option>
<option value="Manufacturer2">Manufacturer2</option>
<option value="Manufacturer3">Manufacturer3</option>
<option selected value="SelectManufacturer">SelectManufacturer</option>
</select></p>
<p><select size="1" name="Brown">
<option selected value="Select Colour">Select Colour</option>
<option value="Red">Red</option>
<option value="Blue">Blue</option>
<option value="Brown">Brown</option>
</select></p>
<p><select size="1" name="rough">
<option selected>Select Texture</option>
<option value="smooth">smooth</option>
<option value="rough">rough</option>
</select></p>
<p><select size="1" name="Pressed">
<option selected value="Select Manufacturing Process">Select Manufacturing Process
</option>
<option value="Wire Cut">Wire Cut</option>
<option value="Hand Made">Hand Made</option>
<option value="Stock">Stock</option>
<option value="Pressed">Pressed</option>
</select></p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>
<p> </p>
</body>
</html>
What i need help with is linking the selection from the drop down menu(s) and running a query if they are selected by pressing submit.
I have four drop downs .. Manufacturer.. colour...texture...manufacturing process
I understand how to query these in SQL, i can filter then by SELECT * FROM mytable WHERE... etc but i dont understand much of how to put it all together into a php page.
Any help appreciated 🙂