Jump to content

Recommended Posts

Hi Guys,

 

I've been using PHP for a few years now but for some reason I can never seem to get my head around arrays, basically I have a blog site that I want to show all posts that have been posted in public categories but ignore those in the private categories, I had the idea to put all the private category ID's into an array and use that to check against the posts, however my array isn't working out the way I'd hoped.

 

This is what I have:

 

$isPrivate = mysql_query("SELECT categoryID FROM mod_cat WHERE isPrivate =1") or die (mysql_error());
while ($isPrivateList = mysql_fetch_array($isPrivate, MYSQL_NUM)) {
$ignoreList = $isPrivateList;
}

 

However this isn't working at all. I know its wrong I just can't work out how to make it right. This is the mySQL I want to use it with:

 

mysql_query("SELECT COUNT(*) AS total_entries FROM mod_posts WHERE articlePosted =1 AND articleCat != $ignorelist")

 

Could anyone please help me?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/213811-excluding-a-category-from-a-list/
Share on other sites

hmm... that didn't work, I'm getting this error:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) AS total_entries FROM mod_posts AS p LEFT JOIN mod_cat AS c ' at line 1

 

This is how I used it:

 

$blogCounter = mysql_query("SELECT COUNT(p.*) AS total_entries FROM mod_posts AS LEFT JOIN mod_cat AS c ON c.categoryID = p.articleCat WHERE p.articlePosted =1 AND c.isPrivate != 1") or die(mysql_error()); $row = mysql_fetch_row($blogCounter); $total_entries = $row[0];

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.