0

hello....

i am doing search concept. i am searching one word from all my web pages .


actually i have only one table for 25 static pages. among this pages i want to search searching content. and also highlight the search content. how to do?

4
Contributors
5
Replies
8
Views
7 Years
Discussion Span
Last Post by ShawnCplus
0

I dont know how to make the function, i would like it so that when the user enters the text it searchs the text on the page and hilites behind the text yellow. So its a bit like a "find" function that hilites behind the word that it is asked to find.

i want only how to highlight bit of word in that pharagraph.

0

Don't know if I understood well, but I guess you need a JavaScript if your highlight should happen dynamically (on the same time person enters the search word). If so, try to Google for JavaScript text highlighting.

-1

I dont know how to make the function, i would like it so that when the user enters the text it searchs the text on the page and hilites behind the text yellow. So its a bit like a "find" function that hilites behind the word that it is asked to find.

i want only how to highlight bit of word in that pharagraph.

try this

function search_highlight($needle, $replace, $haystack)
{
 $haystack = eregi_replace($needle,$replace,$haystack);
 return $haystack;
}
echo search_highlight($searchtext, "<b><font style='color:white; background-color:grey;'>" . $searchtext . "</font></b>", total description);
0

try this

function search_highlight($needle, $replace, $haystack)
{
 $haystack = eregi_replace($needle,$replace,$haystack);
 return $haystack;
}
echo search_highlight($searchtext, "<b><font style='color:white; background-color:grey;'>" . $searchtext . "</font></b>", total description);

thank you pushpa......i got it.

0

try this

function search_highlight($needle, $replace, $haystack)
{
 $haystack = eregi_replace($needle,$replace,$haystack);
 return $haystack;
}
echo search_highlight($searchtext, "<b><font style='color:white; background-color:grey;'>" . $searchtext . "</font></b>", total description);

DON'T use ereg* functions. There's a reason why there are GIANT RED WARNINGS at the top of every page of the PHP documentation with these functions in them. Use preg_*

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.