gpt4 book ai didi

带有自定义显示的 PHP/mysql 搜索

转载 作者:行者123 更新时间:2023-11-29 23:07:31 25 4
gpt4 key购买 nike

我正在尝试使用 php 和 mysql 制作一个简单的搜索引擎。我知道如何使用 php 获取 mysql 结果。它的工作。

ex : - Mysql 数据库存储了这个(数据库表归档“meta”)

I am having some difficulty with my PHP/MySQL search. It worked great a year ago, but for some reason it has just stopped working. I have tried searching and cannot figure it out. I have it echo my query but it never adds in the WHERE clause. Any help is much appreciated. Form Code: PHP Code:

搜索词是搜索

我需要这样显示搜索结果

I have tried searching and cannot figure it out. I have it echo my query but it never adds in the WHERE clause. Any help is much appreciated. Form Code: PHP Code:

最佳答案

	
$query= mysql_query("SELECT meta FROM data WHERE LIKE '%searching%' ");

$count = mysqli_num_rows($query);

if($count >0){
while($row = mysqli_fetch_array($query)) {


echo "$row[id]'>$row[name]</option>";
$count =1;

}
else{
echo "<option value='' selected='selected'></option>";
}
mysqli_close($con);

从上面的代码中,有几个突出的问题:

  1. 该选项的回显没有 open for ,因此不会显示。
  2. 当您从 $row 变量回显信息时,您正在引用 id 和 name,但查询仅输出元。
  3. 查询未在字段中搜索 where 子句,因此失败

据我所知,代码应该更改为以下内容才能工作(假设没有其他周围问题):

$query = mysql_query("SELECT meta, id, name FROM data WHERE meta LIKE '%searching%'");
$count = mysqli_num_rows($query);

if ($count > 0)
{
while ($row = $mysqli_fetch_array($query))
{
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "</option>";
$count = 1; // not sure why this needs to be here, but it's in your code so I'm keeping it there
}
}
else
{
echo "<option value='' selected='selected'></option>";
}

mysqli_close($con);

关于带有自定义显示的 PHP/mysql 搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28233162/

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