Jump to content

Help needed with search engine, syntax error??


BigX

Recommended Posts

Hi guys,

 

I have put together a search engine and I have this code!

 

<?php 
$string = "voor informatie";
$string = strtolower($string);
$split = split(" ",$string);
foreach ($split as $array => $value) {
$new_string .= ''.$value.' ';
}
$new_string=substr($new_string,0,(strLen($new_string)-1));

$split_stemmed = split(" ",$new_string);

$sql = "SELECT DISTINCT * FROM organisaties WHERE ("; 

while(list($key,$val)=each($split_stemmed)){
if($val<>" " and strlen($val) > 0){
$sql .= "(Organisatie LIKE '%.$val.%' OR Algemenebeschrijving LIKE '%.$val.%' OR Trefwoorden LIKE '%.$val.%') OR";
}
}
$sql=substr($sql,0,(strLen($sql)-3));//this will eat the last OR
$sql .= ") ORDER BY id DESC";

$query = mysql_query($sql) or die(mysql_error());
$row_sql = mysql_fetch_assoc($query);
$total = mysql_num_rows($query);

if($total>0) {
while ($row_sql = mysql_fetch_assoc($query)) {
echo ''.$row_sql['Organisatie'].'';
}
} else
{
echo "No results to display";
}
    ?>

 

I gives "No results to display" as a result while I know for a fact that it should give multiple results! I think there is a syntax error somewhere but I cannot find it!

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.