PHP-在MySQL中插入更新删除搜索数据

时间:2018-11-28 04:33:49

标签: php mysql

似乎有问题。当第52行if (mysqli_num_rows{$search_Result})给我解析错误:语法错误,意外。

<?php

$host = "localhost";
$user = "root";
$password = "";
$database ="zebase";
$id="";
$name="";
$address="";
$actnum="";
$status="";
$remarks="";

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
function getPosts()
{

$Post =  array();
$POST[0]= $_POST['id'];
$POST[1]= $_POST['name'];
$POST[2]= $_POST['address'];
$POST[3]= $_POST['actnum'];
$POST[4]= $_POST['status'];
$POST[5]= $_POST['remarks'];
return $posts;
}

if(isset($_POST['search']))
{
$data = getPosts();

$search_Query = "SELECT * FROM thetable WHERE id = $data[o]";

$search_Result = mysqli_query($conn, $search_Query);
}

if ($search_Result)
{

if (mysqli_num_rows{$search_Result})
{
while($row = mysqli_fetch_array($search_Result)}
{

$id =$row['id'];
$name =$row['name'];
$address =$row['address'];
$status =$row['status'];
$remarks =$row['remarks'];

}else {

echo 'No Data For This Id');
}

}else {

echo 'Result Error';
}
}
?>

1 个答案:

答案 0 :(得分:0)

我认为您需要将该行更改为

  

如果(mysqli_num_rows($ search_Result))

如果希望可以解决该错误