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 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; ?> 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 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 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]}%' "); Link to comment https://forums.phpfreaks.com/topic/86071-keyword-search-help/#findComment-440614 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.