0

this is my db table content

tble name : cars
id | make | model | trans | fuel | year | km | vin | regdetails | state | price | features

what i want is search the car with this form

<form id="form1" name="F2" method="post" action="search.php">
  <div style="background-color:#84C8FD; text-align: center;"><h2>Find a Car</h2></div>
  <table width="224" border="0">
  <tr>
    <td width="42">Make</td>
    <td colspan="2"><label for="make"></label>
      <select name="make" id="master">
      <option value="SILECT">Select</option>      
      <option value="AC">AC </option>
      <option value="ALFA ROMEO ">ALFA ROMEO </option>
      <option value="ASIA ">ASIA </option>
      <option value="AMAROO ">AMAROO </option>
      <option value="ASTON MARTIN ">ASTON MARTIN </option>
      <option value="AUDI ">AUDI </option>
      <option value="AUSTIN ">AUSTIN </option>
      <option value="AUSTIN HEALEY ">AUSTIN HEALEY </option>
      <option value="BEDFORD ">BEDFORD </option>
      <option value="BENTLEY ">BENTLEY </option>
      <option value="BERTONE ">BERTONE </option>
      <option value="BMW ">BMW </option>
      </select></td>
    </tr>
  <tr>
    <td>Model</td>
    <td colspan="2"><label for="model"></label>
      <select name="model" id="slave">
      <option value="SELECT">Select</option>
      </select></td>
    </tr>
  <tr>
    <td>Year</td>
    <td width="80"><label for="yearfrom"></label>
      <select name="yearfrom" id="yearfrom">
      <option value="From">From</option>
      </select></td>
    <td width="80"><select name="yearto" id="yearto">
    <option value="To">To</option>
    </select></td>
  </tr>
  <tr>
    <td>Price</td>
    <td><select name="pricefrom" id="pricefrom">
    <option value="From">From</option>
    </select></td>
    <td><select name="priceto" id="priceto">
    <option value="To">To</option>
    </select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input name="" type="submit" value="Search" />&nbsp;</td>
  </tr>
  </table>

  </form>

im new in php so please help me with full scripts

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by network18
-1

this is my db table content

tble name : cars
id | make | model | trans | fuel | year | km | vin | regdetails | state | price | features

<form id="form1" name="F2" method="post" action="search.php">
  <div style="background-color:#84C8FD; text-align: center;"><h2>Find a Car</h2></div>
  <table width="224" border="0">
  <tr>
    <td width="42">Make</td>
    <td colspan="2"><label for="make"></label>
      <select name="make" id="master">
      <option value="SILECT">Select</option>      
      <option value="AC">AC </option>
      <option value="ALFA ROMEO ">ALFA ROMEO </option>
      <option value="ASIA ">ASIA </option>
      <option value="AMAROO ">AMAROO </option>
      <option value="ASTON MARTIN ">ASTON MARTIN </option>
      <option value="AUDI ">AUDI </option>
      <option value="AUSTIN ">AUSTIN </option>
      <option value="AUSTIN HEALEY ">AUSTIN HEALEY </option>
      <option value="BEDFORD ">BEDFORD </option>
      <option value="BENTLEY ">BENTLEY </option>
      <option value="BERTONE ">BERTONE </option>
      <option value="BMW ">BMW </option>
      </select></td>
    </tr>
  <tr>
    <td>Model</td>
    <td colspan="2"><label for="model"></label>
      <select name="model" id="slave">
      <option value="SELECT">Select</option>
      </select></td>
    </tr>
  <tr>
    <td>Year</td>
    <td width="80"><label for="yearfrom"></label>
      <select name="yearfrom" id="yearfrom">
      <option value="From">From</option>
      </select></td>
    <td width="80"><select name="yearto" id="yearto">
    <option value="To">To</option>
    </select></td>
  </tr>
  <tr>
    <td>Price</td>
    <td><select name="pricefrom" id="pricefrom">
    <option value="From">From</option>
    </select></td>
    <td><select name="priceto" id="priceto">
    <option value="To">To</option>
    </select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input name="" type="submit" value="Search" />&nbsp;</td>
  </tr>
  </table>

  </form>

i want to search my db as like in car web site like this site

http://www.carsguide.com.au/

like the find car

im new in php so please help me with full scripts

sorry im not good in English for more explanation

-1

When the user submits the page, build your query depending upon the user's selection.
If the user has selected from_year and to_year, include that in your condition and so on.

0
<?php
if(isset($_POST['submit_or_search_btn']) && $_POST['submit_or_search_btn'] !='')
{
$query = "select car_name from cars where 
//now check if html element is set, add that part to your query too
if($_POST['txt_model_field'] !='') $where .= "model is like ".$_POST['txt_model_field'];
//and so on like this ...

$query_exec = mysql_query($query);
}
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.