i'm trying to check if a value inserted into a taxtbox is different from a value listed on a database.
for now i have this code:
<?php
include('connection.php');
if($_POST)
{
$q=$_POST['search'];
$sql_res=mysql_query("select name, surname, test, from table where name like '%$q%' or surname like '%$q%' order by field (test,1,0)");
while($row=mysql_fetch_array($sql_res))
{
$name=$row['name'];
$surname=$row['surname'];
$test=$row['test'];
$b_name='<strong>'.$q.'</strong>';
$b_surname='<strong>'.$q.'</strong>';
$final_name = str_ireplace($q, $b_name, $surname);
$final_surname = str_ireplace($q, $b_name, $surname);
$display = '<div> HTML code here</div>';
?>
<?php echo $display?>
<?php
}
}
if($final_name != $name){$display = "no";}
?>
and using this code, if the value exist everything works fine, otherwise i have this error:
Notice: Undefined variable: name in C:\xampp\htdocs\A\search.php on line 44
Notice: Undefined variable: final_name in C:\xampp\htdocs\A\search.php on line 44
any help?
EDIT:
Ok, i think that maybe the problem is the live search..
i mean, with your help i can show a message if the $q != $name
but the problem is that this message is always visible at the bottom of the results, and as long as there's no more match, the results disappears and the message is above everything.
I think that maybe just because the search is live, the textbox value is never equal to the database one.
Is it correct?