hi everyone,
can any one help me with this code
<?php
mysql_connect("localhost","root","") or die("could not connect");
mysql_select_db("databasetest") or die("could not find database");
$output = '';
//collect
if(isset($_POST['search'])){
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$query = mysql_query("SELECT * FROM authors WHERE fname LIKE '%$searchq%$' OR lname LIKE '%$searchq%$'") or die("could not search");
$count = mysql_num_rows($query);
if($count == 0){
$output = 'there was no search result!';
}else{
while($row = mysql_fetch_array($query)){
$firstname = $row['fname'];
$lastname = $row['lname'];
$output .= '<div> '.$firstname.' '.$lastname.' </div>';
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>search</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="index.php" method="post">
<input type="text" name="search" placeholder="search" />
<input type="submit" value=">>" />
</form>
<?php print("$output");?>
</body>
</html>
please help
1.when i try to search, ther are no results displayed.