gpt4 book ai didi

php - 显示列中的所有数据

转载 作者:行者123 更新时间:2023-11-29 03:14:30 25 4
gpt4 key购买 nike

我试图在表格的“状态”列中显示所有数据,但遇到了麻烦。我做错了什么:

<?php 
$query1 = "SELECT id, status FROM alerts WHERE customerid='".$_SESSION['customerid']."' ORDER BY id LIMIT $start, $limit ";
$result = mysql_query($query1);

while ($row = mysql_fetch_array($result))
{
echo $row['status'] ;
}
?>

最佳答案

试试这个:

$query1 = "SELECT id, `status` FROM alerts WHERE customerid='".$_SESSION['customerid']."' ORDER BY id LIMIT $start, $limit ";

$result = mysql_query($query1) or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
echo $row['status'];
}

此外,请确保:

$_SESSION['customerid']$start$limit 不为空。您可以使用 echo $query1;

测试构建的查询

注意:mysql_query中添加mysql_error()可以让您查看查询是否有错误。

I am trying to show all of the data in the 'status' column of my table

如果你想显示所有行,你的查询应该是:

$query1 = "SELECT id, `status` FROM alerts ORDER BY id";

但如果您想为特定客户展示,您的查询应该是:

$query1 = "SELECT id, `status` FROM alerts WHERE customerid='".$_SESSION['customerid']."' ORDER BY id";

关于php - 显示列中的所有数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2893641/

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