我需要我的php来打印出所有天气报告以及该人的姓名和电子邮件的HTML表格。 它给了我一个错误 警告:mysqli_stmt :: bind_result():绑定变量的数目不使用php输出sql表格为HTML
这里匹配准备好的声明中字段数是我的代码
$query = "SELECT weather.report,
cities.name, cities.email FROM weather INNER JOIN cities ON weather.city=cities.city ";
$stmt = $mysqli->stmt_init();
if ($stmt->prepare($query)) {
//$stmt->bind_param("s", $player);
$stmt->execute();
$stmt->bind_result($tempCity, $tempReport, $tempName, $tempEmail);
echo "<table width=500 border=1 cellpadding=5>
<tr><th>Temperature</th><th>Report</th><th>City</th><th>DATE</th></tr>";
while ($stmt->fetch()) {
echo "<tr>
<td>".$tempCity."</td>
<td>".$tempReport."</td>
<td>".$tempName."</td>
<td>".$tempEmail."</td>
</tr>\n";
}
echo "</table>";
$stmt->close();
} else {
$error = "Sorry could not retrieve information"; echo $error; return;
}
$mysqli->close();
谢谢你的任何帮助
从字面上看它说什么笑,你需要在查询中选择的项目进行绑定。所以报告,姓名,电子邮件。如果你只绑定三个,你只能在bind_result中有3个,你知道吗? – clearshot66
如果你选择* 3 *项目(报告,名称,电子邮件),你不能绑定4个结果:$ tempCity,$ tempReport,$ tempName,$ tempEmail(编辑:给自己留言:刷新页面之前给予相同的答案^ ^) – OldPadawan
@OldPadawan我完全打算删除那个评论后添加答案haha – clearshot66