gpt4 book ai didi

php - 查询错误,试图通过关键字进行搜索

转载 作者:太空宇宙 更新时间:2023-11-03 11:11:15 25 4
gpt4 key购买 nike

我有一个变量和一个用户名,我想在用户名的字符串(函数描述)上搜索它

这有什么问题:

$function_keywords = mysql_real_escape_string($_POST['function_keywords']);
if($function_keywords=="" || empty($function_keywords)){
redirect("show.php?functions=PHP");
}
//trim whitespace from the stored variable
$trimmed = trim($function_keywords);
//separate key-phrases into keywords
$trimmed_keywords = explode(" ",$trimmed);
// Build SQL Query for each keyword entered
foreach ($trimmed_keywords as $trimm){
// MySQL "MATCH" is used for full-text searching.
//this code is ebv weird , should check out soon!
$query = "SELECT *
FROM functions
WHERE isEnabled=1 AND isPrivate=0
AND function_description LIKE '{$trimm}'
AND user_name='{$user_name}'
";
// Execute the query to get number of rows that contain search kewords
$results=mysql_query ($query,$connection);

最佳答案

就“like”语法而言,您必须使用“%”符号。如果你查询

select * from table where column like '%yourkeyword%'

然后它会返回表列中包含“您的关键字”的所有行。

只有当 column = 'yourkeyword' 时,你的陈述才是正确的

关于php - 查询错误,试图通过关键字进行搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8435003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com