473,383 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

how to highlight search terms


Commonly done, eg. you enter a word in a search engine and when a
hit-page comes up the search word(s) are highlighted.

I'm doing a fulltext search that works well but I've tried a few
"packaged scripts" and haven't got one to work yet. I'm looking for
straightforward understandable way to do this on my MYSQL/PHP pages.

Thanks,
Lee
Jul 17 '05 #1
5 5001
leegold2 wrote:

Commonly done, eg. you enter a word in a search engine and when a
hit-page comes up the search word(s) are highlighted.

I'm doing a fulltext search that works well but I've tried a few
"packaged scripts" and haven't got one to work yet. I'm looking for
straightforward understandable way to do this on my MYSQL/PHP pages.

Thanks,
Lee


To Add: Just to make clear i'm looking for something I can add to my
existing PHP code that does the mysql fulltext search - all works fine.
I want to *add* the hiliting feature. Thanks
Jul 17 '05 #2
On Thu, 14 Oct 2004 00:50:46 GMT, leegold2 <le*****@nospam.net> wrote:
leegold2 wrote:

Commonly done, eg. you enter a word in a search engine and when a
hit-page comes up the search word(s) are highlighted.

I'm doing a fulltext search that works well but I've tried a few
"packaged scripts" and haven't got one to work yet. I'm looking for
straightforward understandable way to do this on my MYSQL/PHP pages.

Thanks,
Lee


To Add: Just to make clear i'm looking for something I can add to my
existing PHP code that does the mysql fulltext search - all works fine.
I want to *add* the hiliting feature. Thanks


This piece from ALA should help.
http://www.alistapart.com/articles/searchhighlight/

Enjoy!

Jul 17 '05 #3
leegold2 <le*****@nospam.net> wrote in message news:<G3kbd.823$WO1.510@trnddc03>...
leegold2 wrote:

Commonly done, eg. you enter a word in a search engine and when a
hit-page comes up the search word(s) are highlighted.

I'm doing a fulltext search that works well but I've tried a few
"packaged scripts" and haven't got one to work yet. I'm looking for
straightforward understandable way to do this on my MYSQL/PHP pages.

Thanks,
Lee


To Add: Just to make clear i'm looking for something I can add to my
existing PHP code that does the mysql fulltext search - all works fine.
I want to *add* the hiliting feature. Thanks


If you pass the search term to the page in the url, you could then use
str_replace to replace all instances of the search term. For example:

$output = str_replace($_GET[searchterm],"<font
color=red>".$_GET[searchterm]."</font>",$output);

I'd imagine this'd take up quite a bit of power and take a while to do
on big pages.
Jul 17 '05 #4
> Commonly done, eg. you enter a word in a search engine and when a
hit-page comes up the search word(s) are highlighted.

I'm doing a fulltext search that works well but I've tried a few
"packaged scripts" and haven't got one to work yet. I'm looking for
straightforward understandable way to do this on my MYSQL/PHP pages.


Does your search engine return the "coordinates" or the places of
discovery for your search patterns?
Can you iterate through a list where any markup can be added for the
highlighting?
Jul 17 '05 #5
"Psythor" wrote:
leegold2 <le*****@nospam.net> wrote in message
news:<G3kbd.823$WO1.510@trnddc03>...
leegold2 wrote:

Commonly done, eg. you enter a word in a search engine and when a hit-page comes up the search word(s) are highlighted.

I’m doing a fulltext search that works well but I’ve tried a few "packaged scripts" and haven’t got one to work yet. I’m looking for straightforward understandable way to do this on my MYSQL/PHP pages.
Thanks,
Lee
To Add: Just to make clear i’m looking for something I can

add to my
existing PHP code that does the mysql fulltext search - all works

fine.
I want to *add* the hiliting feature. Thanks


If you pass the search term to the page in the url, you could then

use str_replace to replace all instances of the search term. For example:
$output = str_replace($_GET[searchterm],"<font
color=red>".$_GET[searchterm]."</font>",$output);

I’d imagine this’d take up quite a bit of power and take a
while to do
on big pages.


This is exactly how phpbb works. Go to phpbb.com, go to forums, and
search for a term. You will see the term carried in the Query String,
and it is highlighted in the text. Actually php is very fast, and I
would not worry about performance --- takes a lot more resources to
load huge text index, than highlight a few words --at least 1000 to 1
in difference.

Come to think of it, download phpbb, and see how they do it.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-highligh...ict160305.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=539437
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: David Morgan | last post by:
Hello I have a little function to highlight text if it exists. Function Highlight(vFind, vSearch) Dim RegEx Set RegEx = New RegExp RegEx.Pattern = vFind RegEx.IgnoreCase = True Highlight =...
5
by: Merx | last post by:
Hi! Is it possible, using Javascript, to highlight (in yellow..) all the occurrences of "number: +" (regex) of the document? Merx
3
by: Nicky | last post by:
hi, all I have an iframe in my page. Actually what I want is just like the google search. When user clicks search, I will load the a page from another URL into iframe and then highlight the key...
2
by: Number 11950 - GPEMC! Replace number with 11950 | last post by:
When you highlight a selection of text represented in an object on a form, somewhere in the Framework or alternatively in the Windows API there exists an array of variables that either contain as a...
2
by: Celeste | last post by:
Hello, I'm trying to parse the referring url for google search terms so that when this page loads it will scroll to and highlight the search term(s). Should i be using document.referrer? ...
0
Merlin1857
by: Merlin1857 | last post by:
A thing I have been asked for on a number of occasions is the ability to highlight text after its been searched for in a record return page. The following does this perfectly. Use this function...
0
by: Mel | last post by:
I have a treeview control that contains a list of filenames which I am searching. If a file in the tree matches the search criteria the entire node is expanded. Often times there are other files...
3
by: yogarajan | last post by:
Dear Friends i am devloping for search box it is woking good i want highlight my search text. My original text is Mixed case (Lower case and upper case) my search text is lower case means how can...
4
by: sangam56 | last post by:
Hi all. I have an iframe in an asp.net web page (Display.aspx). <iframe id="iframe1" runat="server" src="temp/test.html"></iframe> Now I need to highlight a search text, say 'test' in the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.