Hi all,
ive got a search working, as shown below... on the page i want to show how many records are returned, im sure this is pretty simple but cant really work it out.
any help or advice would be much appreiciated :-)
hope the code snippet above helps.
secondly, i may as ask while im here, ive had a problem searching for number ranges, i tried using the 'switch' statement above but it didnt work, so ive resorted adding a column stating 10 - 20 etc and it looks up that field in the table, what is the best way to search for a price range without changing the code above too much?
:-)
many thanks in advance
ive got a search working, as shown below... on the page i want to show how many records are returned, im sure this is pretty simple but cant really work it out.
any help or advice would be much appreiciated :-)
Code:
<?php include "flowermatchdbcnx.php"; $r = $_POST['occcas']; //users choice... e.g. birthday, anniversary etc. $s = $_POST['style']; //display type... modern or classic. $p = $_POST['price']; //price, need to be within the price range. $t = $_POST['type']; //flower suitability.... mother father collegue etc. $pak = $_POST['pacakge']; //flowers packaging //The query to the database $query = ("SELECT * FROM products WHERE style IN ('$s') AND occcas IN ('$r') AND type IN ('$t') AND pacakge IN ('$pak') AND price IN ('$p')"); switch ($p){ case "1":$query=($query." WHERE Price BETWEEN 0 AND 20");break; case "2":$query=($query." WHERE Price BETWEEN 21 AND 30");break; case "3":$query=($query." WHERE Price BETWEEN 31 AND 40");break; case "4":$query=($query." WHERE Price BETWEEN 41 AND 50");break; } $result = mysql_query($query); //while loop to go through database table search all matching records. while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { echo "name :{$row['Product_ID']} <br>"; echo "type :{$row['style']} <br>"; } ?> </body>
secondly, i may as ask while im here, ive had a problem searching for number ranges, i tried using the 'switch' statement above but it didnt work, so ive resorted adding a column stating 10 - 20 etc and it looks up that field in the table, what is the best way to search for a price range without changing the code above too much?
:-)
many thanks in advance
Comment