Jump to content
Sign in to follow this  
adam.jones2

PHP If statment help

Recommended Posts

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);}?>

Edited by adam.jones2

Share this post


Link to post
Share on other sites
$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'

Share this post


Link to post
Share on other sites

That means that the query failed. You should always check for query failures: $numresults=mysql_query ($query);if(!$numresults) { echo mysql_error(); exit;}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...