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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.