Re: [PHP] Re: Php search results]

2002-11-23 Thread Tom Culpepper
I wrote this function to fetch a news item off another web page but with
a little modification it should work for you.  To use it you needed to
identify a set of of strings in the source to use as anchors ($start,
$end) and then it pulls that section and crops off the anchor text so
you are left with just what you wanted.

?
function get_item($url, $start, $end) {
	global $item;
	if(!($fp=fopen($url,r))) {
		echo $url. is not accessable;
		exit;
	}
	while(!feof($fp)) {
		$item.=fgets($fp,255);
	}
	
	fclose($fp);
	$start_position=strpos($item, $start)+strlen($start);
	$end_position=strpos($item, $end);
	$length=$end_position-$start_position;
	$item=substr($item, $start_position, $length);	
}
echo $item;
?

Soemthing like this might work for you:
?
$results=search results;
$keyword=search string;
$startposition=strpos($results, $keyword)-200;
$endposition=strpos($results, $keyword)+200;
$length=$endposition-$startposition;
$item=substr($item, $startposition, $length;
echo $item
?

Tom Culpepper
www.multicasttech.com
[EMAIL PROTECTED]


Alex wrote:
 you could also use regular expressions, but php isn't perl, so good 
luck on
 that one :p.


 Philip Hallstrom [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

You could use strstr() to find the index location of the
string searched for in FIELD.  Then use substr() to return say 50
characters on either side...

-philip

On Thu, 21 Nov 2002, Daniel Masson wrote:


Hello everyone ...

Im working on some kind of search engine for two little tables on text
fields on mssql, and the text fields can be very large fields, im doing
the search with SELECT FIELD FROM TABLE WHERE FIELD LIKE '%SOMTHING%' ..
My question is:

When displaying the search results i dont want to display the entire
field, only the specific parts where the keyword was found , and bold
for the keyword and i just dony know  how to to do that, i mean
displaying the keyword in bold is no problem .. I need to know how to
display only the parts where this keyword is.

Any help will be very helpful

Thanks every1



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php









--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Php search results

2002-11-22 Thread Alex
you could also use regular expressions, but php isn't perl, so good luck on
that one :p.


Philip Hallstrom [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 You could use strstr() to find the index location of the
 string searched for in FIELD.  Then use substr() to return say 50
 characters on either side...

 -philip

 On Thu, 21 Nov 2002, Daniel Masson wrote:

  Hello everyone ...
 
  Im working on some kind of search engine for two little tables on text
  fields on mssql, and the text fields can be very large fields, im doing
  the search with SELECT FIELD FROM TABLE WHERE FIELD LIKE '%SOMTHING%' ..
  My question is:
 
  When displaying the search results i dont want to display the entire
  field, only the specific parts where the keyword was found , and bold
  for the keyword and i just dony know  how to to do that, i mean
  displaying the keyword in bold is no problem .. I need to know how to
  display only the parts where this keyword is.
 
  Any help will be very helpful
 
  Thanks every1
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Php search results

2002-11-21 Thread Philip Hallstrom
You could use strstr() to find the index location of the
string searched for in FIELD.  Then use substr() to return say 50
characters on either side...

-philip

On Thu, 21 Nov 2002, Daniel Masson wrote:

 Hello everyone ...

 Im working on some kind of search engine for two little tables on text
 fields on mssql, and the text fields can be very large fields, im doing
 the search with SELECT FIELD FROM TABLE WHERE FIELD LIKE '%SOMTHING%' ..
 My question is:

 When displaying the search results i dont want to display the entire
 field, only the specific parts where the keyword was found , and bold
 for the keyword and i just dony know  how to to do that, i mean
 displaying the keyword in bold is no problem .. I need to know how to
 display only the parts where this keyword is.

 Any help will be very helpful

 Thanks every1



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php