hello, thx for your posts.
sorry for not being able to answer back, very soon, but i was out ...
... in the mean time I have solved the problem both with displaying results highlited and with searching for manny words.
I still have a question though.
I thought of complicateing the script a little more, and in the same search to search for more fileds.
example
Code: Select all
$field = array("f_name", "l_name", "description");
foreach ($field as $co_name) {
$sql = ....
}
.. but is not working
this is my code so far (just a part of it) and is working great, but i want to search aftr all fields
Code: Select all
$sql = "SELECT *
FROM table
WHERE (valid = 1) ";
for ($i = 0; $i < $size; $i++ )
{
if (($i == 0) && ($i == $size - 1)) {
$sql .= " and '".$col_name."' like '%".$post[$i]."%' ";
$cnd .= " - (char_length(CONCAT(replace(lower('".$col_name."'), lower('".$post[$i]."'), '')))) ";
}
elseif ($i == 0) {
$sql .= " and ('".$col_name."' like '%".$post[$i]."%' ";
$cnd .= " - (char_length(CONCAT(replace(lower('".$col_name."'), lower('".$post[$i]."'), '')))) ";
}
elseif ($i == $size-1) {
$sql .= " or '".$col_name."' like '%".$post[$i]."%') ";
$cnd .= " + (char_length(CONCAT(replace(lower('".$col_name."'), lower('".$post[$i]."'), '')))) ";
}
else {
$sql .= " or '".$col_name."' like '%".$post[$i]."%' ";
$cnd .= " - (char_length(CONCAT(replace(lower('".$col_name."'), lower('".$post[$i]."'), '')))) ";
}
}
$sql .= "ORDER BY char_length(CONCAT('".$col_name."'))";
$sql .= $cnd;
$sql .= "DESC";