Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7703369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:26:31+00:00 2026-05-31T23:26:31+00:00

I have the following script currently, which gets the category IDs as arrays: $sql_select_categories

  • 0

I have the following script currently, which gets the category IDs as arrays:

$sql_select_categories = $db->query("SELECT category_id FROM " . DB_PREFIX . "categories 
                                     WHERE parent_id='" . intval($src_details['parent_id']) . "' 
                                     ORDER BY order_id ASC, name ASC"); 

$additional_vars = set_filter_link($src_details, array('parent_id' => '', 'start' => ''), 'address');

while ($cat_details = $db->fetch_array($sql_select_categories)) {
    $cat_array[$cat_details['category_id']]["name"] = $category_lang[$cat_details['category_id']];
}

if(is_array($cat_array)) {  
    asort($cat_array);

    foreach($cat_array as $key => $value) {     
        $subcat_link = basename($_SERVER['PHP_SELF']) . '?parent_id=' . $key . $additional_vars;

        $output .= '<tr> '.
        '   <td class="contentfont">&nbsp;&raquo; <a href="' . $subcat_link . '">' . $category_lang[$key] . '</a></td> '.
        '</tr> ';
    }
}   
return $output;

This works perfectly, except I need to extract one more variable from the database which is called count. So the MySQL query will change from

SELECT category_id FROM

to

SELECT category_id, count FROM

So far so good, but how do I get it to then display each of the counts in the foreach? I need them displayed in the HTML after $category_lang[$key] as something like $count.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:26:32+00:00Added an answer on May 31, 2026 at 11:26 pm

    Your $cat_details array will have another element that you can reference, which will be $cat_details['count']. You can then add that to your $cat_array like you do with that name element in the while loop.

    $cat_array[ $cat_details['category_id'] ]['count'] = $cat_details['count'];
    

    Make sense?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following script select c.id from .TBL_COUPONS. as c inner join .TBL_BUSINESS.
I have the following jquery script, which deals with a query site-visitors enter to
I currently have the following script: http://jsfiddle.net/oshirowanen/mnXdv/ Which works fine, i.e. if a click
I`m currently working on a script, and I have the following situation. function somnicefunction()
I have the following script which first shows only the first para of the
I have the following script which appears multiple times on my page. I have
I have the following script, which is working for the most part Link to
I have the following script, which works successfully till the last file slice is
I have the following script that I need to adapt to read from a
Hi all i have the following merge sql script which works fine for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.