Forum Moderators: coopster
$select = "SELECT * FROM text WHERE MATCH(content) AGAINST ('".$keyword."') LIMIT 0,50";$query = mysql_query($select);
while ($info = mysql_fetch_object($query)) {
$results[] = $info->content;
}foreach($results as $result) {
echo $result."<br> ";
};
This works pretty well. But I'd like to have snipptes only.
ie
keyword = "new books"
content = "I recently read a new article about information that was published in books a long time ago."
result = "... read a new article about ... published in books a long ..."
Any ideas how to perform this task?
Another way to do it would be split whole text into words, then walk word by word checking if its a match in which case take last and next X words for snippet's purposes.
Can't say whether its the ideal way to do it (I am yet to implement it for my search engine) but it should work well for 10-20 displayed matches :)