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?

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.

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.

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);

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.

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_*

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.