它循环通过,我看到它正确地通过所有数据,但是当我尝试使用$ i将其分配给数组时 - 它只是不断替换它,它不会向数组添加新值
提前致谢!!
$index = "";
$service_singular = "";
$service_plural= "";
$sub_service = "";
$description = "";
$duration = "";
$duration_descript = "";
$price = "";
$i = 0;
if ($fac_id != "" && $fac_id != 0){
if ($stmt = $mysqli->prepare("SELECT `index`,`service_singular`, `service_plural`, `sub_service`, `description`, `duration`, `duration_descript`, `price` FROM `service` WHERE `fac_id`= ?")) {
$stmt->bind_param('s', $fac_id); // Bind "fac_id" to parameter.
$stmt->execute(); // Execute the prepared query.
$stmt->store_result();
// $i = $stmt->num_rows;
$stmt->bind_result($index,$service_singular, $service_plural, $sub_service, $description, $duration, $duration_descript, $price); // get variables from result.
while ($stmt->fetch()){
enter code here
$i = $i++; }
}
答案 0 :(得分:0)
你没有对数组做任何事情:
while ($stmt->fetch()){
$rows[] = array($index, $service_singular, $service_plural, $sub_service,
$description, $duration, $duration_descript, $price);
}
虽然我只使用结果http://php.net/manual/en/mysqli-result.fetch-all.php。