gpt4 book ai didi

php - 使用PHP MYSQL的搜索方法

转载 作者:行者123 更新时间:2023-11-29 12:37:34 26 4
gpt4 key购买 nike

我正在尝试使用搜索作为我的检索选项,这是我最简单的搜索形式,我可以用这些代码做什么,没有错误但不起作用。请指出我的代码有什么问题。提供建议、网站、解决方案谢谢。

    <?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
ob_start();

//connetion database
$dbhost = '192.168.0.9';
$dbuser = 'dsc';
$dbpass = 'csd';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('ERROR CONNECTING TO MYSQL');

$dbname = 'dbtips';
mysql_select_db($dbname);

$output='';

if(isset($_POST['search']))
{
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);

//query
$query = mysql_query("SELECT * FROM tblnews WHERE udate LIKE '%$searchq%'");
$count = mysql_num_rows($query);

if($count==0)
{
$output = 'There was no search result!';
}
else
{
while($row = mysql_fetch_array($query)){
$udate = $row['udate'];
$mis = $row['mis'];
$status = $row['status'];



$output .= '->'.$udate.'-'.$mis.'-'.$status.'<br>';
}
}
}
?>

//form for searching
<form action="search.php" method="POST">
<center>
<p>
<input type="text" size="90" name="search" style="text-align:center">
<br>
<br>
<input type="button" name="searchbutton" value="Search">
<br>
<br>
</p>
</center>
</form>

最佳答案

将其更改为

<input type="button" name="searchbutton" value="Search">

至此

<input type="submit" name="searchbutton" value="Search">

关于php - 使用PHP MYSQL的搜索方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26542277/

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