Page 1 of 1

Select only first four lines, from Sql text field ?

Posted: Tue Nov 30, 2010 7:00 pm
by earngate
Hello,
We want to Find Related Posts from text field of table
we have posts table contain :
id,title,description,keywords,username,hits,comments

we want create sql command to get Related posts by keywords
but keywords field type is text " more than 1 keywords "

how we can do that ???

we tried to use this code

Code: Select all

function more_items_keywords($what,$keywords,$html) {
global $s,$m;
if ($html) $function_name = 'A_parse_part'; else $function_name = 'parse_part';
$where = get_where_fixed_part('',0,0,$s[cas]);$s[more_items_list]=10;
$table = $s[item_types_tables][$what];
$q = dq("select * from $table where keywords = '$keywords' order by hits limit 10",1);
while ($x = mysql_fetch_assoc($q)) $items[] = '<a href="'.get_detail_page_url($what,$x[n],$x[rewrite_url],'',5).'">'.$x[title].'</a>';
if ($items[0])
{ //$a[items] = implode('<br />',$items);
  //$a[title] = $m['more_'.$what];
  return implode('<tr><td class="posts" align="right">',$items);
}
} 
it's extract related posts if keywords field have 1 keyword only !!!
so that how we can Select only first four or six lines, from Sql text field ?

can you help