在我的搜索记录的代码中,在 while 代码块中出现了错误,它无法检索记录。因为需要检索的列数达到了 45 列,所以我没有使用 bind_result 方法。请帮我找出问题所在。
<?php
/* ___Search & display record with MySQLi Prepared Statements ___*/
if(isset($_GET['search'])) {
$cname=$_GET['cname'];
$cname=preg_replace( '/\s+/','',$cname);
if($cname==""){
unset($cname);
$error="Plese enter the company name";
}
else {
require_once '../includes/mysqli_dbconnect.php';
$cname = '%'.$cname.'%';
$query1 = "SELECT * FROM company WHERE cname LIKE ? ORDER BY cname DESC";
$stmt=$dbLink->prepare($query1);
if($stmt===false){
trigger_error('Query Failed'. $query1 . 'Error: ' . $dbLink->error, E_USER_ERROR);
}
$stmt->bind_param('s',$cname);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows > 0 ){
$rs=$stmt->get_result();
while($row=$rs->fetch()){
//here number of columns to show are 45.
echo 'ID: '. $row['id']. '<br/>';
echo 'Company: '. $row['cname']. '<br/>';
}
}else{
echo 'No Record Found';
}
$stmt->close();
$dbLink->close();
}
}
?>