$color = yellow;
function highlight_word( $content, $word, $color ) {
$replace = '
' . $word . ''; // create replacement
$content = str_ireplace( $word, $replace, $content ); // replace content
return $content; // return highlighted data
}
function highlight_words( $content, $words, $color ) {
// loop through words
foreach( $words as &$word ) {
$content = highlight_word( $content, $word, $color ); // highlight word
}
return $content; // return highlighted data
}
if (empty($_REQUEST["ltbSearch"])) {
echo '
';
include_once("includes/baggsconfig.php");
if (mysqli_connect_errno()) {
printf("Unable to connect. Connection failed: %s\n", mysqli_connect_error());
exit();
}
$stmt = $mysqli->prepare("SELECT ID, LTBArchive, LTBArchiveItem, Material, DatePlace, Notes1, Notes2 FROM BAGGSArchive ORDER BY LTBArchive, LTBArchiveItem ASC");
$stmt->bind_result($ID, $ltb, $item, $material, $dateplace, $notes1, $notes2);
$stmt->execute();
$stmt->store_result();
echo '
The A.E. Baggs LTB Inventory
';
echo '
';
echo 'LTB # | Item | Material | Date / Place | Notes 1 | Notes 2 |
';
while($stmt->fetch()) {
echo '';
echo '' . $ltb . ' | ';
echo '' . $item . ' | ';
echo '' . $material . ' | ';
echo '' . $dateplace . ' | ';
echo '' . $notes1 . ' | ';
echo '' . $notes2 . ' | ';
echo '
';
}
echo '
';
}
if (!empty($_REQUEST["ltbSearch"])) {
echo '
';
include_once("includes/baggsconfig.php");
if (mysqli_connect_errno()) {
printf("Unable to connect. Connection failed: %s\n", mysqli_connect_error());
exit();
}
if(preg_match("/[a-zA-Z0-9_-]/", $_REQUEST["ltbSearch"])){
$ltbSearch=$_REQUEST["ltbSearch"];
$ltbSearch=$mysqli->real_escape_string($ltbSearch);
$where = " (Material LIKE '%" . $ltbSearch . "%') OR (DatePlace LIKE '%" . $ltbSearch . "%') OR (Notes1 LIKE '%" . $ltbSearch . "%') OR (Notes2 LIKE '%" . $ltbSearch . "%')";
if (empty($where)) {
header("Location: https://www.tworedroses.com/ltbarchives.php");
}
else{
$stmt = $mysqli->prepare("SELECT * FROM BAGGSArchive WHERE" . $where . "ORDER BY LTBArchive, LTBArchiveItem ASC");
}
$stmt->bind_result($ID, $ltb, $item, $material, $dateplace, $notes1, $notes2);
$stmt->execute();
$stmt->store_result();
$words = explode(' ', $ltbSearch);
if($stmt->num_rows > 0) {
echo $stmt->num_rows . ' results for “
' . $ltbSearch . '” found:';
echo '
The A.E. Baggs LTB Inventory
';
echo '
';
echo 'LTB # | Item | Material | Date / Place | Notes 1 | Notes 2 |
';
while($stmt->fetch()) {
echo '';
$ltb = highlight_words($ltb, $words, $color);
echo '' . $ltb . ' | ';
$item = highlight_words($item, $words, $color);
echo '' . $item . ' | ';
$material = highlight_words($material, $words, $color);
echo '' . $material . ' | ';
$dateplace = highlight_words($dateplace, $words, $color);
echo '' . $dateplace . ' | ';
$notes1 = highlight_words($notes1, $words, $color);
echo '' . $notes1 . ' | ';
$notes2 = highlight_words($notes2, $words, $color);
echo '' . $notes2 . ' | ';
echo '
';
}
echo '
';
}
else {
echo '
No Results Found
';
echo "
Sorry, we could not find a match for your search: “" . $ltbSearch . "”.
";
echo "
Please check your entry for accuracy and try again or click here to go back to the complete LTB Archives listing.
";
echo '
The A.E. Baggs LTB Inventory
';
echo '
';
echo 'LTB # | Item | Material | Date / Place | Notes 1 | Notes 2 |
';
echo '
';
}
mysqli_close($mysqli);
}
}
?>