lopes_andre Posted March 8, 2009 Share Posted March 8, 2009 Hi, I'am a novice programmer. And I'am with some dificulties in this code... if (!empty($c_pesquisa)) { if (empty($aCategoria)) { $query_ = $query_ . " c_anuncio like '%{$c_pesquisa}%'"; } else { $query_ = $query_ . " AND c_anuncio like '%{$c_pesquisa}%'"; } } The variable $aCategoria is an array, the values inside the array are all "null" in my debug but the code jumps to "$query_ = $query_ . " AND c_anuncio like '%{$c_pesquisa}%'";" instead of "$query_ = $query_ . " c_anuncio like '%{$c_pesquisa}%'";" What I'am doing wrong? Best Regards, André. Quote Link to comment Share on other sites More sharing options...
corbin Posted March 8, 2009 Share Posted March 8, 2009 If an array contains any values it will not be empty, whether the values are null, "", or what ever. (array() is considered empty.) You will either have to unset() null key/val pairs, or you will have to make a function that looks for a value in an array that is not null. Quote Link to comment Share on other sites More sharing options...
lopes_andre Posted March 8, 2009 Author Share Posted March 8, 2009 Thanks a lot! I will find a solution. Best Regards, André. 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.