I’m about to update my search script. The search engine searches in my database where I ask it to search. What is new is I want do some search words, that the users can check in a checkbox, if he wants to use the word in the search.
As for now my search engine works, the only problem is that it only searches the last word and not all of the checked words. My formula looks like this:
[php]<form method=“POST” action="<?=$_SERVER["PHP_SELF"]?>">
Search for:
Books: Movies: Outdoor: Indore: [/php]The php code looks like:
[php]<?php
if(isset($_POST[‘search’]))
{
$connx = mysql_connect(‘localhost’, ‘’, ',**’) or die(“connx”);
$db = mysql_select_db(’*********’) or die(mysql_error());
convert to upper case, trim it, and replace spaces with “|”:
$search = mysql_real_escape_string($search);
$search = strtoupper(preg_replace(’/\s+/’, ‘|’, ($_POST[‘search’])));
create a MySQL REGEXP for the search:
$regexp = “REGEXP ‘[:<:][[:>:]]’”;
$query = "SELECT * FROM keywords
WHERE UPPER(keywords01
) $regexp OR ".
"keywords02
$regexp OR ".
"keywords03
$regexp OR “.
"keywords04
$regexp”;
$result = mysql_query($query) or die($query . " - " . mysql_error());
echo “
<img src=…/{$row[‘type’]}/{$row[‘folder’]}/{$row[‘date’]}-{$row[‘num’]}/{$row[‘thumbimage’]} border=1> | ”;{$row[‘name’]} | ”;{$row[‘date’]} | ”;<a href=…/view.php?id={$row[‘id’]} target=blank>VIEW | ”;