Helo,我使用“bind_result”,“LIKE CONCAT”......通过两个查询字符串来实现全文搜索和分页。
但是如何将 bind_result 方法更改为 fetch_assoc?
<?php
$mysqli = new mysqli("localhost", "", "", "test");
$query_string="hello"; //keywords
$sqltxt="SELECT * FROM `table` WHERE text1 LIKE CONCAT('%', ?, '%')";
//first query : for get the total number of data
$stmt = $mysqli->prepare($sqltxt);
$stmt->bind_param("s",$query_string);
$stmt->execute();
$stmt->store_result();
$total =$stmt->num_rows;
$lastpage = ceil($total/20);//obtain the last page
$page=$_GET["page"];
$startpoint = ($page * 20) - 20;
//second query : for get the true data
$stmt = $mysqli->prepare($sqltxt ." LIMIT {$startpoint}, 20");
$stmt->bind_param("s",$query_string);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($id,$title,$tel); //<= hits!! I want to using fetch_assoc methods
while($stmt->fetch()){ //<= hits!! I want to using fetch_assoc methods
echo $id;
echo $atitle;
echo $tel;
}
?>
谢谢!