Ok, I implemented your solution and got the same result.
As in only the active products are listed?
Double check the test data in your database. Also, remove this line since it is unnecessary and yet has potential to introduce confusion:
$status = $row["status"];
but it should not be the problem.
However, there is a bigger problem that I did not notice earlier. On each iteration of the while loop, you retrieve a product, not a category. This means that in order to list the products within a category, you need to sort the results returned, and then use some additional logic to determine when a category begins.
The sorting by category is easy. Change the query to:
$sql = "SELECT * FROM products WHERE status = '$status' AND category IN ($category_list) ORDER BY category";
Now, grouping by category is a little harder. The logic will be something like this:
if (mysql_num_rows($result) > 0) {
// Append current status heading.
$content .= '...';
$current_category = '';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
if ($row['category'] != $current_category) {
// The current product is from a new category.
$current_category = $row['category'];
// Append current category heading.
$content .= '...';
}
// Append current product details.
$content .= '...';
}
}