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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:58:07+00:00 2026-06-16T22:58:07+00:00

I have a calendar set up in a mySQL table and I am trying

  • 0

I have a calendar set up in a mySQL table and I am trying to output the dates via monthly calendars (Jan, Feb, Mar) which accounts for the “missing days” for previous months and the following month.

So if I am trying to make a calendar for Jan 2013 and Jan 1 falls on a Tuesday — I am having difficulty coding a method to show that Sun Dec 30 and Mon Dec 31 act as “space fillers” or what have you… know what I mean?

I am having a difficult time wrapping my head around how to output this info.

The data structure and data is as follows:

Table_name: sched_calendar_table

dt  y   q   m   d   dw  monthName   dayName w   isWeekday   isHoliday   holidayDescr    isPayday
2010-01-01  2010    1   1   1   6   January Friday  0   1   1   New Year's Day  0
2010-01-02  2010    1   1   2   7   January Saturday    0   0   0       0
2010-01-03  2010    1   1   3   1   January Sunday  1   0   0       0
2010-01-04  2010    1   1   4   2   January Monday  1   1   0       0
2010-01-05  2010    1   1   5   3   January Tuesday 1   1   0       0

I plan on creating each monthly calendar using tables.

So the initial part of the code is:

echo '<table>';
$sql="SELECT * FROM sched_calendar_table WHERE y=2013";
$result=mysql_query($sql);
while($row=mysql_query($result)){
 echo '<tr><td>'; // .. unsure how to account for the placeholder days that aren't part of the month being displayed... how to do this?
}
echo '</table>';
  • 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-16T22:58:08+00:00Added an answer on June 16, 2026 at 10:58 pm

    Quick function, that returns all dates by weeks, start with monday, end with sunday (even if that dates are from after/before month).

    function getWeekDays($month, $year)
    {
        $dFrom = new DateTime("$year-$month-01");
        $dTo = clone $dFrom;
        if (($N = $dFrom->format('N')) > 1) {
            $dFrom->modify('-' . ($N - 1) . ' day');
        }
        $dTo->add(new DateInterval('P1M'));
        if (($N = $dTo->format('N')) < 7) {
            $dTo->modify((8 - $N) . ' day');
        }
    
        $p = new DatePeriod($dFrom, new DateInterval('P1D'), $dTo);
    
        $datesByWeek = array();
        foreach ($p as $d) {
            $datesByWeek[ $d->format('W') ][] = $d;
        }
        return $datesByWeek;
    }
    

    Example:

    print_r( getWeekDays(1, 2013) );
    

    Now you have all dates that represent current month, so you can do DB magic…

    How to output table from this data, see > Find weekly periods (starting on a Monday) for a month

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

Sidebar

Related Questions

I have a calendar table in my MYSQL database with one field named datefield
I have a MySQL Server set to UTC (@@global.time_zone = '+00:00') and a table
I have a calendar application which has the ability to set pill reminders. ScheduledToastNotification
I have a mysql table with users and their weekly calendar. Every user can
Right so I have a simple app that consists of a calendar a Set
My app draws a calendar. I have an ivar, _cal, set to -[NSCalendar autoupdatingCurrentCalendar]
I have a calendar program that I am trying to convert to iPad (using
I have a calendar table with data from year 2000 to 2012 (2012 wasn't
I have this code Calendar c = new GregorianCalendar(); c.add(Calendar.DAY_OF_YEAR, 1); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE,
I've have a problem trying to print a given period between two dates. Let

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.