PDA

View Full Version : Search and Advanced Result Page


shoapin
12-12-2011, 03:56 PM
Can someone please help me?

I have a search page with two list menu and two radio buttons.
The user of the site can select from the list/menu car, jeep, motocycle and
The two radio buttons have sale or rent
When the submit button is pressed i need check if jeep is selected search the correct database or if jeep and sale are selected, search the correct database and put it on a seperate results page.

I am very new to php, and the if statements and while statements are killing me, i have searched and searched for help but no one seems to know how to submit this multiple parameter form.

Thanks in adavance

shoapin
12-12-2011, 05:44 PM
Here is html, i'm lost on the PHP

<form id="searcMennuu" name="searcMennuu" method="post" action="VehicleListing.php">
<select name="vehicles" id="vehicles">
<option value="allCars" selected="selected">ALL</option>
<option value="Sedan">Sedan</option>
<option value="Jeep">Jeep</option>
<option value="Motorbike">Motorbike</option>

</select>

<input name="radioVehicle" type="radio" id="searchSale" value="searchSale" />
Vehicles for Sale</label>
<label>
<input type="radio" name="radioVehicle" id="searchRent" value="searchRent" />
Vehicles for Rent</label>

<input type="submit" name="searchButton" id="searchButton" value="Search" />
</form>

edbr
12-13-2011, 01:17 AM
well if you save the above (as a test) as something.php it will submit to itself as i changed the action. All values are submited.

<form id="searcMennuu" name="searcMennuu" method="post" action="">
<select name="vehicles" id="vehicles">
<option value="allCars" selected="selected">ALL</option>
<option value="Sedan">Sedan</option>
<option value="Jeep">Jeep</option>
<option value="Motorbike">Motorbike</option>

</select>

<input name="radioVehicle" type="radio" id="searchSale" value="searchSale" />
Vehicles for Sale</label>
<label>
<input type="radio" name="radioVehicle" id="searchRent" value="searchRent" />
Vehicles for Rent</label>

<input type="submit" name="searchButton" id="searchButton" value="Search" />
</form>


<?php foreach($_POST as $var => $value)
{
echo $var . ' : ' . $value . "<br>";
}
?>

so what do you want to do with them?

edbr
12-13-2011, 01:29 AM
sorry just read your post more carefully
When the submit button is pressed i need check if jeep is selected search the correct database or if jeep and sale are selected, search the correct database and put it on a separate results page.

you need to write a select statement like this



$vehicle= $_POST['vehicle']
$sale= $_POST['radioVehicle']

// this will simplify the Post array

// edit to your table and field names

select * from table where vehicle= $vehicle AND sale=$sale

this is just basic and values must match values in your database.
You may enter a problem if the radio buttons are not selected so you could make one default