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";
精彩评论