I am creating a search function and i want to select say only 100 characters (or pref. 40 words) before and after the returned phrase in the results. so far i am using:
$get = mysql_query("SELECT * FROM posts WHERE content LIKE '%".quote_smart($query)."%' ORDER BY $order") or die("Cannot search: ".mysql_error());
i tried to use SELECT id, title, tid, uid, LEFT(content, 50) FROM POSTS.... but the query returned none of the content? any ideas?
I would rather keep whole words than chop bits up. thanks
Edit:
Also i need to pass several variables in pagination script but i don't want to use GET as a method; i would rather use POST, anyway of doing this via a normal link or my using global variables?
Edit 2:
Am now using:
$sql = mysql_query("SELECT id, uid, tid, date, SUBSTRING_INDEX(content, ' ', 25) AS stuff FROM posts WHERE content LIKE '%".quote_smart($term)."%' ORDER BY $order $dir LIMIT $limit, $lastlimit") or die("Cannot search: ".mysql_error());
but this can actually cut off the term.. hmm.