开发者

Show all data in column

I am trying to show all of the data in the 'status' column of my table but am having troubles. What 开发者_开发技巧am I doing wrong:

<?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'] ;
}
?>


Try this:

$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'];
}

Also, make sure that:

$_SESSION['customerid'], $start and $limit are not empty. You can test the constructed query with echo $query1;

Note: Addition of mysql_error() in in the mysql_query will allow you to see if there is an error in the query.

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

If you want to show all the rows, your query should be:

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

But if you want to show for a specific customer, your query should be:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜