Page 1 of 1

echo and highlighting problem

Posted: Sun Apr 06, 2003 9:08 am
by japaja
My part of code is...

query=trimmed

Code: Select all

// now you can display the results returned
  while ($row= mysql_fetch_array($result)) {
  $title = $rowї"ttitle"];
  $string = ereg_replace ("<br />", " ", $ttitle);
  $title2 = $row&#1111;"ID"];
  $title3 = $row&#1111;"texxt"];
  $title4 = $row&#1111;"datee"];
  $results = "$title3";
  $results = "$replaced";
 
 
// highlighting code
$search=str_replace(" ","|", $trimmed);
$replaced=preg_replace("/(&#123;$search&#125;)/i","<b><font color=#ffoooo>\\1</font></b>",$title3);
$search=str_replace("%","|", $trimmed);
 
//echo links
  echo "$count.)
  &nbsp;
  <a href="something\\details.php?strid=$title2">$string</a>";
  echo "<br />";
 
 
// echo only 150 first characters
$length = 150;
$mySubstring = ereg_replace("^(.&#123;1,$length&#125;)&#1111; .,].*", "\\1", $results);
$text = $mySubstring.' ...';

//echo search result..not all code just
        echo (...$title4...etc...$text);


Now, when I'm using this code, my first result is only printing ... cos of

Code: Select all

($text = $mySubstring.' ...';)
huh, without any description and with no matter what searching keyword is.

example of search result :

1) ...

//cos of this from above, but second, third, fourth etc. and all others searching results "echo" first 150 characters like

2) something blah blah 150 characters then ...

3) something blah blah 150 characters then ...

etc



I want to first result also have some description too, and just to say, that searching keyword is highlighted in all that results

AND

when I changed this code with

Code: Select all

// now you can display the results returned
  while ($row= mysql_fetch_array($result)) &#123;
  $title = $row&#1111;"ttile"];
  $string = ereg_replace ("<br />", " ", $title);
  $title2 = $row&#1111;"ID"];
  $title3 = $row&#1111;"texxt"];
  $title4 = $row&#1111;"datee"];
// I changed it like this...  just rotate...
  $results = "$replaced";
  $results = "$title3";
Then I'm without highlighting but with description in the first searching result

WHY?

p.s.
I wish, hmm, that all searching results are with description and highlighting keyword, and not only 2,3,4,5 without the first one !!!