Building a query string
| From: | Ed Curtis | Date: | Wed, 03 Dec 2003 16:27:38 +0000 |
| Subject: | Building a query string | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-171685@lists.php.net to get a copy of this message | ||
This list has helped me out alot and I hope it can do it one more time.
I need to build a MySQL query based on 11 different options from a form.
Some options will have values others will be checkboxes to say include in
the query.
How I thought about going at it was using a default query string and add
additional strings to the default string based on results of the form.
$query_str = "SELECT * FROM listings WHERE id > 0 ";
if ($garage != "") {
$garage_str = "AND garage = '$garage' ";
//add $garage_str to $query_str//
}
This would continue through all eleven options then produce a query string
with all included query options needed. Can this be done this way? If so,
how do I add a string to a string?
Thanks,
Ed