Dear Nasreen,
  You could also do something like this:

$query = "select * FROM gig g, venue v, genre ge ";

if($gig_name) {
 $wheres[] = "g.gigName LIKE '%".$gig_name."%'";
if($gig_date) {
 $wheres[] = "g.gig_date LIKE '%".$sdate."%'";

if(is_array($wheres)) {
  $wheres = implode(" OR ", $wheres);
  $query .= " WHERE $wheres";

This has fewer if statements than basing it off of the number of fields and then checking 
if a value exists to add the " OR " between the statements.

Beth Tucker
php|architect Trainer

Check out the latest issue of php|architect Magazine:

Join us in Atlanta, GA, November 12 - 14, 2008
Explore the Possibilities at php|works
Call for papers open until July 25th

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to