Search query returning all records in database when they are no records

could we see it please?

When i echo $query_rsTest i get this

“SELECT year, model FROM vehicles”

when i echo $totalRows_rsTest

I get 20, which are the total number of records i have in the database

Nearly there I thiink, now show us the result of


var_dump($_POST);

which should be added to your postback form handler script, temporarily.

I put it after $query_rsTest = “SELECT year, model FROM vehicles”; hope that was the right place.

It returned “Array (0) {}”

this explains why you are returning all rows in the table, correct?

you’ve forgotten the WHERE clause

Well, it seems you are not POST ing anything to the form handler?

If you selected vehicle “Jeep” from the list and submitted the form when you var_dump the POST vars you should see the likes of :


array('vehicle' => 'Jeep') 

Show us the html which is generated for the page with the form on it (ie html “view source”)

So what do i need to put there.

Also when i put it after the defined variables i get

eg.
var_dump($_POST[‘vehicles’]);

string(8) “Sedan”

You said:

My problem is when i try to search for sedan and there are no sedans in my database i display all records, how do i get the query to display nothing if there is nothing in my database.

So when you fill in your form, select “Sedan” what does


 echo $query_rsTest;  

… give you?

Also, try changing this line


if (isset ($_POST ['vehicles']) && ($_POST ['radioVehicles'])) { 

to this (for now)


if (isset ($_POST ['vehicles']) ) {