How do I write a PHP search code for multiple criterias?
Say if I have a table with data about cars and it has three columns: Make, Mode, and Year. How do I write a PHP query code that will search the table with multiple criterias? I've only been able to do a search by one criteria at a time, like this:
mysql_query("SELECT*FROM cars WHERE make='$make'")
If I try searching for multiple criterias like this, it won't work:
mysql_query("SELECT*FROM cars WHERE make='$make' model='$model' year='$year'")
Anyone here good at PHP?
Comments
It's an sql question, not php.
but here is the solution:
<?php
//...
if (get_magic_quotes_gpc()){
$_GET = array_map('stripslashes', $_GET);
$_POST = array_map('stripslashes', $_POST);
$_COOKIE = array_map('stripslashes', $_COOKIE);
}
$query = addslashes("SELECT * FROM cars WHERE make='$make' and model='$model' and year='$year'");
$result = mysql_query($query);
//...
?>
"Tublet: extra suitable than a mouthful is a waste while you're a mouse." "Tublet: the faster picker-top." "Tublet: Love her or hate her, you already know you are able to no longer have her, so drink that yee beer, fluff up your breasteses, and run like helll..." <---- have been given nuthin' (unhappy) (
mysql_query("Select * from cars Where make='$make' And model='$model' AND year='$year'");
newboston.com has a boat load of videos on that
check mysql.com to FULLTEXT SEARCH .. its best!
try it from
http://experthelps.com/