tags:

views:

22

answers:

1

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'] ;
}
?>
+1  A: 

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";
Web Logic
Completely missed the variables $start and $limit. They were both blank Thankyou!
@user: You are welcome......
Web Logic