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 Link to comment https://forums.phpfreaks.com/topic/77870-hate-to-bother-you-one-last-time-tonight-but/ 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 Link to comment https://forums.phpfreaks.com/topic/77870-hate-to-bother-you-one-last-time-tonight-but/#findComment-394143 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.