adam.jones2 Posted February 15, 2012 Share Posted February 15, 2012 Can anyone help we as to why this is not working, When you form is submited with value of "" i want it to search everything <?phpinclude ("db.php"); //Connect to the database using values from db.php ajones_cardealer $database variable value from db.php$connect = mysql_connect($host,$username,$password) or die('<p class="error">Unable to connect to the database server at this tim</p>'); //select the database we are going to use in this case itsmysql_select_db($database,$connect) or die('<p class="error">Unable to connect to the database at this time.</p>'); // Get the posted value based on option select. $Make = $_POST['make'];$Min_Price = $_POST['pf'];$Max_Price = $_POST['pt']; // Create SQL query to find the row with make_id.$query = "SELECT * FROM site_cars WHERE car_Make = $Make AND car_price BETWEEN $Min_Price AND $Max_Price";// Execute the query to get number of rows that contain search kewords$numresults=mysql_query ($query);$row_num_links_main =mysql_num_rows ($numresults);//output results//If Query doesn't return any results search * if($row_num_links_main < 1){ $query_all = "SELECT * FROM site_car"; $numresults=mysql_query ($query_all); $row_num_links_main1 = mysql_num_rows ($numresults);}?> Link to comment Share on other sites More sharing options...
Don E Posted February 15, 2012 Share Posted February 15, 2012 $query_all = "SELECT * FROM site_car"; site_car should be site_cars I believe. Also try putting single quotes around $Make in the first query: '$Make' Link to comment Share on other sites More sharing options...
adam.jones2 Posted February 16, 2012 Author Share Posted February 16, 2012 updated and get this error Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\\quicksearch.php on line 3 Link to comment Share on other sites More sharing options...
Ingolme Posted February 16, 2012 Share Posted February 16, 2012 That means that the query failed. You should always check for query failures: $numresults=mysql_query ($query);if(!$numresults) { echo mysql_error(); exit;} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.