Jump to content

Can't Echo the Count


unemployment

Recommended Posts

I am trying to echo the count for blog posts that have not been review yet, but I get this error.

 

Notice: Undefined index: status

 

but I feel like I have defined my status in my query.  Plus my query is working as I have checked it in phpmyadmin

 

Here is my function:

 

function unapproved_post_counter()
{
$sql = "SELECT
			COUNT(`approved`) AS `status`
		FROM `blog_posts`
		WHERE `approved` = 0
		";

$result = mysql_query($sql);

$data = array();

while (($row = mysql_fetch_assoc($result)) !== false)
{
	$data[] = $row;
}

return $data;

}

 

Here is how I am echoing it.

 

$count	= unapproved_post_counter();

<h1>Blog<span class="blogadds f_right"><?php echo $count['status']; ?> New Articles</span>

 

print_r($count) tells me this...

 

Array ( [0] => Array ( [status] => 2 ) )

 

Link to comment
https://forums.phpfreaks.com/topic/232172-cant-echo-the-count/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.