gpt4 book ai didi

php - 查询输出未显示在页面上

转载 作者:行者123 更新时间:2023-11-30 22:36:39 26 4
gpt4 key购买 nike

我有以下不显示任何内容/工作的查询/输出。所有的列表名称都是正确的。我有 php 错误检查,它没有抛出任何错误。

这是没有输出任何内容的代码。

$total_members_query = $con->prepare("SELECT COUNT(id)FROM users WHERE `group` IN (2,3,4,5)")
or die ("Total Members query failed: %s\n".($total_members_query->error));
$total_members_query->execute();
$total_members_query->bind_result($total_members);
$numrows_members = $total_members_query->num_rows();
// $numrows_members = mysqli_num_rows($total_members_query);
if($numrows_members > 0){

while($members_row = mysqli_fetch_assoc($total_members_query)){
//$members_total = $members_row['id'];
?>
<div class="member_summary_statistics">
<div class="member_summary_category_title">League Statistics</div>
<div id="member_summary_member_count">Members in your league: <?php echo $total_members; } } ?></div>

这里有更多代码。略高于和低于它。

<div class="member_summary_user_birthdays">
<div class="member_summary_category_title">Today&#39;s Birthdays</div>
</div>
<?php
$total_members_query = $con->prepare("SELECT COUNT(id)FROM users WHERE `group` IN (2,3,4,5)")
or die ("Total Members query failed: %s\n".($total_members_query->error));
$total_members_query->execute();
$total_members_query->bind_result($total_members);
$numrows_members = $total_members_query->num_rows();
// $numrows_members = mysqli_num_rows($total_members_query);
if($numrows_members > 0){

while($members_row = mysqli_fetch_assoc($total_members_query)){
//$members_total = $members_row['id'];
?>
<div class="member_summary_statistics">
<div class="member_summary_category_title">League Statistics</div>
<div id="member_summary_member_count">Members in your league: <?php echo $total_members; } } ?></div>
<div id="member_summary_newest_member">Welcome our newest member - <?php echo $member_username;?>!</div>

& 符号之后的这一行中的所有内容在我的文件管理器中都显示为灰色,而不是黑色和蓝色。

Today&#39;s Birthdays</div>

然后我的两个标题没有出现在生日文本之后..

class="member_summary_category_title">League Statistics</div>
<div id="member_summary_member_count">Members in your league:

我不知道这是否与正在发生的事情有关,因为我已经一遍又一遍地查看它,但无法弄清楚任何事情。

如果有任何帮助,我将不胜感激。

最佳答案

看起来您在 prepare 语句中的 COUNT(id)FROM 之间缺少一个空格。

编辑:您还需要缓冲结果集,请参阅 Mysqli documentation :

$total_members_query->execute();
$total_members_query->bind_result($total_members);
$total_members_query->store_result();
$numrows_members = $total_members_query->num_rows;

编辑 2:仔细查看您的陈述,我意识到您的查询将始终返回一行(因为 COUNT 至少为 0),为什么您可能想要采用这样的方法:

<?php
$total_members_query = $con->prepare("SELECT COUNT(id) as countId FROM users WHERE `group` IN (2,3,4,5)")
or die ("Total Members query failed: \n" . ($total_members_query->error));
$total_members_query->execute();
$total_members_query->bind_result($total_members);
$total_members_query->fetch();
if($total_members > 0){
?>
HTML-code...

关于php - 查询输出未显示在页面上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32357595/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com