petenaylor Posted May 3, 2012 Share Posted May 3, 2012 Hi all Can I add another question statement into this? So if the string $keywords is 'Keywords' or if it's empty have an empty SQL statement? Otherwise "AND ..." $keyword_search = $keywords === 'Keywords' ? '' : "AND job_title LIKE '%$keywords%' OR job_short_desc LIKE '%$keywords%' OR job_long_desc LIKE '%$keywords%'" Many thanks Pete Quote Link to comment https://forums.phpfreaks.com/topic/262022-add-question-statement/ Share on other sites More sharing options...
Jessica Posted May 3, 2012 Share Posted May 3, 2012 Yes, you can. Quote Link to comment https://forums.phpfreaks.com/topic/262022-add-question-statement/#findComment-1342719 Share on other sites More sharing options...
petenaylor Posted May 3, 2012 Author Share Posted May 3, 2012 Great thanks! Can you help by showing me where it goes in my code? Quote Link to comment https://forums.phpfreaks.com/topic/262022-add-question-statement/#findComment-1342731 Share on other sites More sharing options...
jcbones Posted May 3, 2012 Share Posted May 3, 2012 $keyword_search = ($keywords === 'Keywords' || empty($keywords)) ? '' : "AND job_title LIKE '%$keywords%' OR job_short_desc LIKE '%$keywords%' OR job_long_desc LIKE '%$keywords%'" Quote Link to comment https://forums.phpfreaks.com/topic/262022-add-question-statement/#findComment-1342828 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.