Hi all, ive got a search function running on a database, the action performed by the form is shown below, within the 'else' statement i would like to show roughly 5 random rows from the sql table (alternative products) if you like.
please find below the script im currently running for the search, the else statment just shows 'no results found' message at the moment.
many thanks in advance for any who can help:
please find below the script im currently running for the search, the else statment just shows 'no results found' message at the moment.
many thanks in advance for any who can help:
Code:
<table width="40%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><img src="graphics/sunflowerbanner.jpg" width="830" height="227" /></td> </tr> <tr> <td><?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')"); $result = mysql_query($query); $result_count = mysql_num_rows($result); //while loop to go through database table search all matching records. if ($row = mysql_fetch_array($result)) { //start of table... sets table headers echo "<table border='1'><tr><td>name</td><td>type</td></tr>"; //returns results and puts them in ajoining table printf ("<tr><td>%s</td><td>%s</td><td>%s</td></tr></table>",$row[8], $row[6], $row[5]); }else { echo "there were no matches found, please find some alternatives below"; } ?></td> </tr> <tr> <td><div align="center"><?PHP echo "$result_count\n"; ?></div></td> </tr> </table>
Comment