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

  • Home
  • SEARCH
  • 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 8355669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:56:04+00:00 2026-06-09T09:56:04+00:00

I have a simple array which has been used before with no problems. Now

  • 0

I have a simple array which has been used before with no problems. Now I am trying to use it again and it is displaying nothing for text (Even in view source).

Array:

$month = Array(
    1 => "January",
    2 => "February",
    3 => "March",
    4 => "April",
    5 => "May",
    6 => "June",
    7 => "July",
    8 => "August",
    9 => "September",
    10 => "October",
    11 => "November",
    12 => "December"
);

Code:

function getMonthlyStats($comic_id) {
    require "config.php";
    $query = 'SELECT *, SUM(views) AS `views` FROM '.$db_tbl_stats.' WHERE '.$db_fld_stats_comic_id.'="'.$comic_id.'" GROUP BY '.$db_fld_stats_month.' ASC';
    $r_query = mysql_query($query);
    while ($result = mysql_fetch_array($r_query)) {
    $percent = ($result[$db_fld_stats_views]/getTotalStats($comic_id))*100;
    $m = number_format($result['month']);
        echo '<tr>';
        echo '<td width="100">&nbsp;&nbsp;';
        echo $month[$m];
        echo '</td>';
        echo '<td width="400" class="bar"><div style="width: '.$percent.'%"></div>'.$result[$db_fld_stats_views].' Views</td>';
        echo '<td>'.number_format($percent).'%</td>';
        echo '</tr>';
    }

}

$m returns a number from 1-12 which obviously represents a month.

If you need more info I will be happy to explain more. Any help is greatly appreciated! Going on 4 hours writing and my eyes are tired.

  • 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-06-09T09:56:06+00:00Added an answer on June 9, 2026 at 9:56 am

    You need to add global $month; to your function, or use $GLOBALS['month'] instead of $month.

    This is called “variable scope”. See http://php.net/manual/en/language.variables.scope.php for more details.

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

Sidebar

Related Questions

If I have a variant array which holds nothing but simple types, and possible
So i have a class name repository which is just a simple array.Here is
I have a simple function which takes an array of characters as an argument,
I have a simple array with x number of items. I am displaying them
I have a simple array of stuff: $array = array(apples,oranges,strawberries); I am trying to
I have an simple array array = [apple, orange, lemon] array2 = [[apple, good
I have a simple array with bank holidays: var bank_holidays = ['06/04/2012','09/04/2012','07/05/2012','04/06/2012','05/06/2012','27/08/2012','25/12/2012','26/12/2012','01/01/2013','29/03/2013','01/04/2013','06/05/2013','27/05/2013']; I want
I have a simple JavaScript Array object containing a few numbers. [267, 306, 108]
I have a simple associative array: $ar = array( 1=>'foo', 2=>'bar', 5=>'foobar', 8=>'barfoo' )
I have a simple simulated array with two elements: bowl["fruit"] = "apple"; bowl["nuts"] =

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.