memphisweb Posted November 18, 2007 Share Posted November 18, 2007 Ok, last bit of code, am trying to eliminate and error trap null fields on a search --- 4 criteria search - image size, opco, campaign, and open searhc to display all results in database //handles the variables for image size posting to display all images if ( $campaign > 0 ) { $sqlcampaign="campaign_id=$campaign"; } if ( $opco > 0 ) { $sqlopco=" company_id=$opco"; } // handling for 0 search criteria // no opco or campaign selected if ( $opco == 0 && $sqlcampaign == 0) { $bannersearchquerybuild = "WHERE $sqlwidth"; } // no opco selected if ( $opco == 0 && $sqlcampaign > 0) { $bannersearchquerybuild = "WHERE $sqlwidth AND $sqlcampaign"; } // no campaign selected if ( $opco > 0 && $sqlcampaign == 0) { $bannersearchquerybuild = "WHERE $sqlwidth AND $sqlopco"; } //no image size selected if ( $imagesize == "0" ) { $bannersearchquerybuild = "WHERE $sqlcampaign AND $sqlopco"; } // no opco selected, no campaign, no size if ( $opco == 0 && $sqlcampaign == 0 && $sqlwidth ==0) { $bannersearchquery = " SELECT file_set.* FROM file_set"; } else { $bannersearchquerybuild= "$sqlwidth AND $sqlcampaign AND $sqlopco"; $bannersearchquery = "SELECT file_set.* FROM file_set WHERE $bannersearchquerybuild"; } just having a bear of a time trapping out if one has an empty vallue Thanks again for help Quote Link to comment Share on other sites More sharing options...
Barand Posted November 18, 2007 Share Posted November 18, 2007 this is my method http://www.phpfreaks.com/forums/index.php/topic,167302.msg737240.html#msg737240 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.