$ row中的未定义索引

时间:2019-05-05 21:38:31

标签: php mysql

您好,我正在制作带有表格的高分网页。到目前为止,我有两个工作,而我的最后一个给我带来麻烦。数据是播放的时间,以秒为单位存储。这是我的查询

我尝试过的东西

$project

我尝试了一些不同的变体,但没有一个适合我。我相信这是我缺乏知识,仅此而已。我90%的人需要在其中添加$project来执行检查,但我只是不知道isset的工作原理,我发现的所有示例都非常复杂。像这样。

    <?php if( isset($this->attr['totaltime'])) { ?>
        <td><?php echo $row['totaltime']; ?></td>

<?php   } ?>

2 个答案:

答案 0 :(得分:3)

第二个数据库列没有名称,只是Floor函数的匿名结果。

您应为该列使用别名,例如

SELECT utime.playername, FLOOR(utime.totaltime / 3600) as totaltime FROM utime.utime ORDER BY utime.totaltime DESC LIMIT 10

这将与您用来在PHP中引用它的索引名匹配

答案 1 :(得分:0)

我建议您进行一些调试。 foreach将行作为关联数组返回。 PHP提供了一种遍历while循环的关联数组的方法。 您可以做的是在foreach循环的主体内,添加while ($row = mysqli_fetch_assoc($utimer)) { for ($row as $key -> $value){ echo "<br>Key: ". $key . " Value: ". $value } } 循环

while

删除$key循环的其余部分,让我知道您得到了什么。 totaltime将包含字段名称,即playername$valueasync function createUser(usuario:Usuario) { let user try { await admin.auth().createUser({ email: usuario.email, password: usuario.senha, }) .then(userRecord => { user = userRecord; }); await userRole(usuario.role, user); await db.collection('usuario').doc(user.uid).set(usuario); await db.doc('usuario/'+user.uid).update({uid:user.uid}); const retorno = await 'O usuário '+`${usuario.nomeCompleto} `+'foi cadastrado com sucesso, recebendo o acesso de '+`${usuario.role}`; return retorno; } catch (error) { return error.message; } } 该行的数据。让我知道你得到什么。 希望这会有所帮助!