PHP_ie Posted April 16, 2007 Share Posted April 16, 2007 can anyone offer advice on this? I want to be able to limit what is selected for the database with a number of drop down menus, but can't get it working. <?php include("test_sbumit.php"); echo"<br>"; echo"<br>"; printf("Your current category is: %s", $_SERVER['QUERY_STRING']); echo"<br>"; echo"<br>"; $category = $_SERVER['QUERY_STRING']; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("alpha", $con); echo "<form action='showproducts.php' method='POST'>"; echo "<table border='1'>"; echo "<tr>"; echo "<td>"; echo "<a>price: €</a>"; echo "<select name='price'>"; echo "<option value='all'>All</option>"; echo "<option value='499'>0 - 499</option>"; echo "<option value='999'>500 - 999</option>"; echo "<option value='1499'>1000 - 1499</option>"; echo "<option value='1999'>1500 - 1999</option>"; echo "<option value='2000'>2000 +</option>"; echo "</td>"; echo "<td></td>"; echo "<td><input type='submit' value='go'></td>"; echo "</tr>"; echo "</table>"; If ($price != "All"){ $result = mysql_query("SELECT prodID, title, price FROM product WHERE category='$category' AND price<'$price'"); while($row = mysql_fetch_array($result)) { printf("<a href='showone.php?%s'>%s</a> %s <br> ",$row['prodID'],$row['title'],$row['price']); } } mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/47244-narrowing-sql-select-using-a-number-of-variables/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.