MikeDXUNL Posted January 15, 2008 Share Posted January 15, 2008 say the Database Field: `keywords` consists of 'halo 3 xbox 360 master chief' now $by = keywords automattically unless stated otherwise. so the url = http://myurl.com/search.php?halo+xbox&whereat=videogames i want the mysql_query to look like "SELECT * FROM $whereat WHERE $qu ORDER BY releasedate ASC" <?php $re = split(" ", $q); $i=0; while($i < count($re)) { $qu = " $by LIKE %".$re[''.$i.'']."% OR"; $i++; } ?> any help on how to piece together the query i desire is thanked in advance - Mike Quote Link to comment https://forums.phpfreaks.com/topic/86071-keyword-search-help/ Share on other sites More sharing options...
rajivgonsalves Posted January 15, 2008 Share Posted January 15, 2008 try this <?php $re = explode(" ", $q); $arrCondition = array(); $qu = ""; for ($i=0;$i<count($re);$i++) { array_push(" $by like '%{$re[$i]}%' ",$arrCondition); } $qu = implode(" OR ",$arrCondition); print $qu; ?> Quote Link to comment https://forums.phpfreaks.com/topic/86071-keyword-search-help/#findComment-439530 Share on other sites More sharing options...
MikeDXUNL Posted January 15, 2008 Author Share Posted January 15, 2008 when I try, I get the Syntax Error: Fatal error: Only variables can be passed by reference in C:\wamp\www\vgant\search.php on line 296 line 296: array_push(" $by like '%{$re[$i]}%' ",$arrCondition); I tried to edit the go about of quotation marks, but cant seem to figure it out.. any help? Thanks, Mike Quote Link to comment https://forums.phpfreaks.com/topic/86071-keyword-search-help/#findComment-440153 Share on other sites More sharing options...
MikeDXUNL Posted January 16, 2008 Author Share Posted January 16, 2008 bump Quote Link to comment https://forums.phpfreaks.com/topic/86071-keyword-search-help/#findComment-440589 Share on other sites More sharing options...
rajivgonsalves Posted January 16, 2008 Share Posted January 16, 2008 lolz I got the syntax wrong this array_push(" $by like '%{$re[$i]}%' ",$arrCondition); should be array_push($arrCondition," $by like '%{$re[$i]}%' "); Quote Link to comment https://forums.phpfreaks.com/topic/86071-keyword-search-help/#findComment-440614 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.