PHP Search Engine

Hello,
I am trying to get this search engine to search for more than two keywords.
I have got a script which I need to change but unfortunately it’s not working. I have tried to do it multiple ways. But at the moment it is searching for just username and name;

The first source;

[php]
$queryMsg = sprintf(“SELECT * FROM users WHERE username RLIKE ‘%s’ OR name RLIKE ‘%s’ ORDER BY idu DESC LIMIT %s”, mysql_real_escape_string(str_replace(’ ‘, ‘|’, $_GET[‘u’])), mysql_real_escape_string(str_replace(’ ', ‘|’, $_GET[‘u’])), $resultSettings[1]);
[/php]

[php]
$queryMsg = sprintf(“SELECT * FROM users WHERE username RLIKE ‘%s’ AND idu < %s OR name RLIKE ‘%s’ AND idu < %s ORDER BY idu DESC LIMIT %s”, mysql_real_escape_string(str_replace(’ ‘, ‘|’, $_POST[‘u’])), mysql_real_escape_string($loadmore), mysql_real_escape_string(str_replace(’ ', ‘|’, $_POST[‘u’])), mysql_real_escape_string($loadmore), $resultSettings[1]);
[/php]

This is the bit I need to change.

It would be great to have your help.

Johnny :slight_smile:

Try this:
[php]$queryMsg = sprintf(“SELECT * FROM users WHERE username RLIKE ‘%s’ OR name RLIKE ‘%s’ AND idu < %s ORDER BY idu DESC LIMIT %s”, mysql_real_escape_string(str_replace(’ ‘, ‘|’, $_POST[‘u’])), mysql_real_escape_string(str_replace(’ ', ‘|’, $_POST[‘u’])), mysql_real_escape_string($loadmore), $resultSettings[1]);
[/php]

If you wish to search more, add another OR statement after the OR name part and then add another $_POST[‘u’] part.

Hope it helps,
Red :wink:

cheers mate it works. ;D

no worries, glad i could help :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service