header("content-type:text/html;charset=utf-8");
//Get user data
$keywords=$_POST['keywords'];
//Connect to the database
$c or die('Database link failed');
//Select the database and set the character set
mysql_select_db('search');
mysql_set_charset('utf8');
//php fuzzy query
if(empty($keywords )){
$str= "Please enter the content you want to query";
}else{
$sql="SELECT * FROM user WHERE username LIKE '%$keywords%'";
}
$rs=mysql_query($sql );
$users = array();
while($row=mysql_fetch_assoc($rs)){
//Highlight replacement
$row['username'] = str_replace($keywords, ''.$keywords.'', $row['username']);
$users[] = $row;
}
//print_r($users);
?>
UID | Gender | Interests | ||
---|---|---|---|---|
".$value['uid']." | ";".$value['sex']." | ";".$value['hobby']." | ";
The above introduces the PHP fuzzy query example code, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.