$word1 = explode(" ",$word); // Extract the words from $word and store them in array $word1. All words in $word must be seperated by spaces.
$operator = "|"; // Set regex operator to "|".
if($word)
{
$word = "'"; // Prepare $word for new string
for($i=0;$i<count($word1);$i++)
{
if($word1[$i] && $word1[$i] != "") // Check to see if $word started or ended with a space or contains multiple spaces.
{
$word .= $word1[$i].$operator; // Add the words to $word
}
}
$word = substr($word,0,strlen($word)-1); // Remove the last "|"
$word .= "'"; // Add closing ' to $word
if($word == "'"){$word = "' '";}
$result = mysql_query("SELECT * FROM exemple WHERE town RLIKE $word AND kind RLIKE '$soort' AND rooms RLIKE '$kamers' AND size >= '$woonopp' AND size2 >= '$perceelopp' AND price BETWEEN '$pricefrom' AND '$pricetill'") or die(mysql_error());
}
else{
$result = mysql_query("SELECT * FROM exemple WHERE kind RLIKE '$soort' AND rooms RLIKE '$kamers' AND size >= '$woonopp' AND size2>= '$perceelopp' AND price BETWEEN '$pricefrom' AND '$pricetill'")
or die(mysql_error());
}
$num_rows = mysql_num_rows($result);
If($num_rows < 1 || !$num_rows)
{
echo "No results.";
}
else
{
while($row = mysql_fetch_array($result))
{
// Print out the contents of each row
echo $row["adress"]." - ".$row["town"]."<br />";
}
}
It works great with me... but there is something I couldn't manage:
I want 4 items found to be displayed... under these items I want a row with a number of pages (1-2-3-4-5-6...) what shows the other results.
$word = "'"; for($i=0;$i<count($word1);$i++) { if($word1[$i] && $word1[$i] != "") // Check to see if $word started or ended with a space or contains multiple spaces. { $word .= $word1[$i].$operator; // Add the words to $word } } $word = substr($word,0,strlen($word)-1); // Remove the last "|" $word .= "'"; // Add closing ' to $word if($word == "'"){ $word = "' '"; }
$result = mysql_query("SELECT * FROM aanbod WHERE adres RLIKE $word OR plaats RLIKE $word OR verhaal RLIKE $word") or die(mysql_error());
$total_items = mysql_num_rows($result);
$num_rows = mysql_num_rows($result);
if($num_rows < 1 || !$num_rows) { echo "Er zijn geen resultaten gevonden voor u zoekopdracht. Pas uw zoekcriteria aan en probeer het nogmaals."; } else {