Posted on: 10/20/02 07:16am
By: griffman
...
if (($type == 'links') || (($type == 'all') && empty ($author))) {
$sql = "SELECT lid,title,url,hits,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon,UNIX_TIMESTAMP(date) as day FROM {$_TABLES['links']} WHERE ";
$sql .= " (title like '%$query%' ";
$sql .= " OR description like '%$query%')
...";
...
if (($type == 'links') || (($type == 'all') && empty ($author))) {
$sql = "SELECT lid,title,url,hits,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon,UNIX_TIMESTAMP(date) as day FROM {$_TABLES['links']} WHERE ";
if (substr_count($query,",") == 0) { // no commas, so no WORD searches
$sql .= " (title like '%$query%' ";
$sql .= " OR description like '%$query%') ";
} else {
$mywords = explode(",",$query);
$tmp = "";
foreach ($mywords as $mysearchterm) {
$tmp .= "(title like '%" . trim($mysearchterm) . "%' OR ";
$tmp .= "description like '%" . trim($mysearchterm) . "%') AND";
}
$tmp = substr($tmp,0,strlen($tmp)-4);
$sql .= $tmp;
}
...
...
$sql = "SELECT sid,title,hits,uid,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon,UNIX_TIMESTAMP(date) as day,'story' as type FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) ";
if (!empty ($query)) {
$sql .= "AND (introtext like '%$query%' ";
$sql .= "OR bodytext like '%$query%' ";
$sql .= "OR title like '%$query%') ";
}
...
...
$sql = "SELECT sid,title,hits,uid,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon,UNIX_TIMESTAMP(date) as day,'story' as type FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) ";
if (!empty ($query)) {
if (substr_count($query,",") == 0) { // no commas, so no WORD searches
$sql .= "AND (introtext like '%$query%' ";
$sql .= "OR bodytext like '%$query%' ";
$sql .= "OR title like '%$query%') "
} else { // need to do WORD searches
$mywords = explode(",",$query);
$sql .= "AND ";
$tmp = "";
foreach ($mywords as $mysearchterm) {
$tmp .= "(introtext like '%" . trim($mysearchterm) . "%' OR ";
$tmp .= "bodytext like '%" . trim($mysearchterm) . "%' OR ";
$tmp .= "introtext like '%" . trim($mysearchterm) . "%') AND ";
}
$tmp = substr($tmp,0,strlen($tmp)-4);
$sql .= $tmp;
}
}
Posted on: 10/21/02 12:54pm
By: akerin
Posted on: 10/25/02 10:07pm
By: griffman
foreach ($mywords as $mysearchterm) {
$tmp .= "(introtext like '%" . trim($mysearchterm) . "%' OR ";
$tmp .= "bodytext like '%" . trim($mysearchterm) . "%' OR ";
$tmp .= "introtext like '%" . trim($mysearchterm) . "%') AND ";
The last line needs to have introtext replaced with title.
Sigh; almost got it all right! ;-)
-rob.
Posted on: 10/27/02 09:03am
By: rv8
Has anyone got this to work? If so, I would love to get a copy of your search.php file. I tried it on my local server, but now I get:
Parse error: parse error, unexpected '}' in /Library/WebServer/Documents/search.php on line 276
I don't know enough php to figure out what is wrong.
Thanks,
Kevin
Posted on: 10/27/02 12:00pm
By: rv8
Well, I did a bunch of experimenting, and it looks like there are two additional problems with the code to be inserted in function searchstories.
First, there needs to be a semicolon at the end of the third $sql line. It should look like:
$sql .= "OR title like '%$query%') ";
Second, the last } must be removed, at the very end of the code to be inserted.
I made these changes and everything seems to work correctly now. I also went into the english.php file and changed the line that comes up in the Advanced Search dialog to explain the new functionality.
Kevin
Posted on: 11/22/02 01:25am
By: Anonymous (Anonymous)
Posted on: 04/03/03 03:02pm
By: muskrat