我安装了一个非常简单的搜索脚本,它完成了它应该做的事情,除非它返回结果,它会在返回的数据结果之前显示这些信息:
object(mysqli_result)#2(5){[“current_field”] => int(0)[“field_count”] => int(36)[“lengths”] => NULL [“num_rows”] => int(1)[“type”] => int(0)}
我能做些什么,所以这不会发生吗?
这是search.php页面:
<?php
$con=mysqli_connect("xxxx","xxxx","xxxx","xxxx") or die('Error connection');
$data = '';
if(isset($_POST['search']))
{
$keyword = $_POST['search'];
$keyword = preg_replace("#[^0-9a-z]#i","",$keyword);
$query = "SELECT * FROM characters WHERE name LIKE '%$keyword%' ORDER BY name";
$result = mysqli_query($con,$query);
var_dump($result);
$count = mysqli_num_rows($result);
if($count>0)
while($row = mysqli_fetch_array($result))
{
$data = $data."<div>".$row['name']."</div>";
}
}
?>
<?php echo $data; ?>
想出来了!谢谢你的帮助!