Hello guys,
I'm trying to highlight the keywords that the user enter to search through the database.I know there is a hightlight_string() function is PHP.Can some one show me how to use it?
Below are the codes for searching the database:
<?php
include("password.php");
mysql_connect (localhost, $User, $Password);
mysql_select_db ($DBName);
if ($question == ""){
$question = '%';
}
if ($answer == ""){
$answer = '%';
}
$Table = $Category;
$result = mysql_query ("SELECT * FROM $Category WHERE question LIKE '%$question%'AND answer LIKE '%$answer%'");
if ($row = mysql_fetch_array($result)) {
do {
print"<b>";
print($row["question"]);
print"</b>";
print(" ");
print"<br>";
print($row["answer"]);
print("<p>");
} while($row = mysql_fetch_array($result));
}else {
print "Sorry, no records were found!";
}
//}
?>