close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Keyword highlight help

Thread began 3/15/2012 8:37 am by info364504 | Last modified 3/15/2012 12:02 pm by info364504 | 524 views | 2 replies

Jason ByrnesWebAssist

it _can_ be done, but is not supported and requires some hand coding to accomplish.

one way it could be done would be to store the search terms in a session variable, then using the php preg_replace() function, search the rescordset results for the string, and replace with a span tag using the color style

the following code is an example of how this can be done, in this example the search forms method was set to POST.

the first block sets session variables for each POST element using the name "['searchTerms']['<elementName>']". so if I have a form element named "name", the value of the name form element will be stored in a session named "['searchTerms']['name']"

the second block is a function to do the highlighting, it takes 2 arguments, the name of the element and the data to search.

$_SESSION['searchTerms'])) unset($_SESSION['searchTerms']);
$_POST as $k => $v) {
$v != "") {
$_SESSION['searchTerms'][$k] = $v;

doHighLight($elemName$haystack) {
$_SESSION['searchTerms'][$elemName]) && $_SESSION['searchTerms'][$elemName] != "") {
$termsArr explode(" "$_SESSION['searchTerms'][$elemName]);
$needleArr = array();
$i=0;$isizeof($termsArr) ; $i++) {
$needleArr[] = "{".$termsArr[$i]."\b}i";

$retstr "";
$retstr preg_replace($needleArr"<span style=\"color:red;\">$0</span>"$haystack);
    } else {

in the results page, the code to display a recordset column may look like this:

<?php echo $row_recordsetName['ProductName']); ?>

we can change this to perform the highlighting by adding the doHighLight function call around it.

in my example,, the name of the form element that searches the "ProductName" column is "name", so the doHighLight function call will look like this:

<?php echo doHighLight("name"$row_recordsetName['ProductName']); ?>

like i said, this is not supported functionality, but with some familiarity with PHP coding, you should be able to use the example as a starting point.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...