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 8755159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:47:36+00:00 2026-06-13T13:47:36+00:00

$jan5 = 0; $feb5 = 0; $mar5 = 0; $apr5 = 0; $may5 =

  • 0
$jan5 = 0;
$feb5 = 0;
$mar5 = 0;
$apr5 = 0;
$may5 = 0;
$jun5 = 0;
$jul5 = 0;
$aug5 = 0;
$sep5 = 0;
$oct5 = 0;
$nov5 = 0;
$dec5 = 0;
$jan4 = 0;
$feb4 = 0;
$mar4 = 0;
$apr4 = 0;
$may4 = 0;
$jun4 = 0;
$jul4 = 0;
$aug4 = 0;
$sep4 = 0;
$oct4 = 0;
$nov4 = 0;
$dec4 = 0;
$jan3 = 0;
$feb3 = 0;
$mar3 = 0;
$apr3 = 0;
$may3 = 0;
$jun3 = 0;
$jul3 = 0;
$aug3 = 0;
$sep3 = 0;
$oct3 = 0;
$nov3 = 0;
$dec3 = 0;  

this is the most time consuming code when i try to make for example i want the default value of $jan5 is equal to zero.. can some one teach me how to make this short? thank you so much for reading

$date = 'smi_initialdate';
$level = 'smi_level';
$year = '2012';

$result1 = mysql_query("SELECT *, DATE_FORMAT( $date, '%m' ) As monthz FROM eis_mngt_sales_iti WHERE year($date) = '$year' ORDER BY $date");
while($row=mysql_fetch_array($result1))
{
$count++;


    if($row['smi_level']=='5star')
    {
        if($row['monthz']==1)
        {
        $jan++;
        }elseif($row['monthz']==2)
        {
        $feb++;
        }elseif($row['monthz']==3)
        {
        $mar++;
        }elseif($row['monthz']==4)
        {
        $apr++;
        }elseif($row['monthz']==5)
        {
        $may++;
        }elseif($row['monthz']==6)
        {
        $jun++;
        }elseif($row['monthz']==7)
        {
        $jul++;
        }elseif($row['monthz']==8)
        {
        $aug++;
        }elseif($row['monthz']==9)
        {
        $sep++;
        }elseif($row['monthz']==10)
        {
        $oct++;
        }elseif($row['monthz']==11)
        {
        $nov++;
        }elseif($row['monthz']==12)
        {
        $dec++;
        }
    }   
}

i decide to put this $jan5 = 0;$feb5 = 0;$mar5 = 0;$apr5 = 0;$may5 = 0;$jun5 = 0;$jul5 = 0; so that if the data did not pass to this condition if($row['smi_level']=='5star') they have the return value of zero(0).

so that my output can adapt in this code

[<?php  echo$jan5.",".$feb5.",".$mar5.",".$apr5.",".$may5.",".$jun5.",".$jul5.",".$aug5.",".$sep5.",".$oct5.",".$nov5.",".$dec5;
?]

if a dont use the above code the $jan5 = 0;$feb5 = 0;$mar5 = 0;$apr5 = 0;$may5 = 0;$jun5 = 0;$jul5 = 0;................ when i echo or print it i look like this
1,2,5,11,12 but with the use of that(the first sample code above) the output will be 1,0,0,0,0,0,0,1,2,5,11,12.

thank, sorry if this became confusing, sorry about my grammar

  • 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-13T13:47:37+00:00Added an answer on June 13, 2026 at 1:47 pm

    This may do the trick…

    $month = array('jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');
    $day = array(3,4,5);
    
    foreach($day as $d)
    {
        foreach($month as $m)
        {
            ${$m.$d} = 0;
        }
    }
    

    But i recommend you to use Array.

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

Sidebar

Related Questions

I would like to build a very basic daily sales report. I'm am trying
I've tried doing my research on this, found this website: http://www.lullabot.com/blog/importexport-large-mysql-databases and still am
I am a newbie in PHP & wordpress. I wanted to know how to
Is there away i can sort the following array into the correct order? Array
After switching my Rails 2.3 app from MRI Ruby 1.8.7 to JRuby 1.6.5, the
I'm trying to connect jconsole to a jvm invoked by: java \ -Djava.util.logging.config.file=./logging.properties \
When I SELECT a Geometry column with AsText() , the returned value is truncated
In the spirit of not reinventing the wheel, can anyone point me to free
When I do ruby-1.9.2-p180 :002 > Curl::Multi.download([http://www.bbc.com]) => nil The downloaded file is of
The post on calculating trend lines on a scatter plot ( How do I

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.