user342391
user342391

Reputation: 7827

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

Upvotes: 2

Views: 327

Answers (1)

Web Logic
Web Logic

Reputation:

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";

Upvotes: 1

Related Questions