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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:34:37+00:00 2026-06-19T02:34:37+00:00

This is rather weird, and rather complicated, im going to try to explain it

  • 0

This is rather weird, and rather complicated, im going to try to explain it as best as i can. im making a calendar by hand, plan on open sourcing it etc. Im currently going for the look and feel of google calendar, as they seem to be the best, however i do plan on one upping it + open source. Everything is running flawlessly except when i click previous month, in order to view previous month, then ajax query is ran, the php returns the new calendar, but when it renders it renders without the ANY <table> elements other than that havent hit a snag yet any ideas? heres some code/images:

html:

//function to use xml
function xml(){
 //need to set up xml to run php for query
   if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
   }
   else
   {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
   xmlhttp.onreadystatechange = function()
   {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
     document.getElementById("calendar").innerHTML= xmlhttp.responseText;
    }
  };
}

//function to select the previous month
function previousMonth(str){
//since this is the previous month we need to take month -1
var month = str - 1;
 //if it is already 1.. then it needs to be 12!
  if(str == 1)
  {
   month = 12;
  }
   //call xml
   xml()
   //send dat query
   xmlhttp.open("GET","redraw.php?month="+encodeURIComponent(month),true);
   xmlhttp.send();
}

redraw.php:

// draws the calendar 
function draw_calendar($month,$year){
  // table headings 
  $headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
  $calendar= '<tr class="calendar-row"><td class="calendar-day-head" id = "cell" style = "min-width:150px;">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>';

  // days and weeks vars now 
  $days_last_month = date('t',mktime(0,0,0,$month-1,1,$year));
  $running_day = date('w',mktime(0,0,0,$month,1,$year));
  $days_in_month = date('t',mktime(0,0,0,$month,1,$year));
  $days_in_this_week = 1;
  $day_counter = 0;
  $dates_array = array();
  $today = date("d");

  // row for week one 
  $calendar.= '<tr class="calendar-row">';

  // print "blank" days until the first of the current week 
  for($x = 0; $x < $running_day; $x++)
  {
    $calendar.= '<td class = "calendar-day-prev" id = "cell" style = "min-width:150px;"><div class = "day-prev-    number" style = "color:#929D9D">'.(($days_last_month -($running_day - 1)) + $x).'</div>';
    $calendar.= str_repeat('<p>&nbsp;</p>',2);
    $calendar.= '</td>';
    $days_in_this_week++;
  }

  // keep going with days....
  for($list_day = 1; $list_day <= $days_in_month; $list_day++)
  {
   $calendar.= '<td class = "calendar-day" id = "cell" style = "  min-width:150px;"';
  //if the day is today we obviously need to have a differnet style for it... 
    if($list_day == $today)
    {
     $calendar.= ' style = "background-color:#9494B8;font-weight:bol;">';
    }
    else
    {
     $calendar.= '>';
    }

      // add in the day number 
      $calendar.= '<div class = "day-number">'.$list_day.'</div>';

      // THIS IS WHERE I NEED TO QUERY ENTRIES PER DAY
      $calendar.= str_repeat('<p>&nbsp;</p>',2);

    $calendar.= '</td>';
    if($running_day == 6)
    {
      $calendar.= '</tr>';
      if(($day_counter+1) != $days_in_month)
      {
        $calendar.= '<tr class="calendar-row">';
      }
      $running_day = -1;
      $days_in_this_week = 0;
    }
    $days_in_this_week++; $running_day++; $day_counter++;
  }

  // finish the rest of the days in the week 
  if($days_in_this_week < 8 && $days_in_this_week != 1)
  {
    for($x = 1; $x <= (8 - $days_in_this_week); $x++)
    {
      $calendar.= '<td class = "calendar-day-after" id = "cell" style = "  min-width:150px;"><div class = "day-post-number" style = "color:#929D9D;">'.$x.'</div>';
      $calendar.= str_repeat('<p>&nbsp;</p>',2); 
      $calendar.= '</td>';
    }
  };

  // final row 
  $calendar.= '</tr>';

  // all done, return result 
  return $calendar;

}

//draw the calendar
$year = date ('Y');
$month_title = date ('F');

//Sent variables
if(!empty($_REQUEST['month']))
{
  $month_display = $_REQUEST['month'];
}
else
{
  $month_display = date ('n');
}
echo draw_calendar($month_display,$year);

heres a good depiction of whats going on:

what it should look like:
start

on the first click:
onclick

what is inserted by the js into the <div id = "calendar">
kinda works

what is returned by the php(this part is seemingly correct):
bad

  • 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-19T02:34:38+00:00Added an answer on June 19, 2026 at 2:34 am
    document.getElementById("calendar").innerHTML= xmlhttp.responseText;
    

    You are inserting table rows into a div, not a table. Add the missing table tag or append the data into the table.

    NITPICKS – You have “header cells” but you do not use th elements. You are not using thead and tbody.

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

Sidebar

Related Questions

I know this is rather laughable, but I can't seem to get simple C++
It may seems rather newbie question, but can you explain why method Der.B() cannot
This is rather weird. When I do a Svn update, tortoise tells me that
Maybe this is going to sound like a real weird thing I want to
This must be easier than I am making it, but I am going crazy
I can't recall how, but I came up with this weird repository state, At
This is a rather weird problem and I been at it for a while
I looked at this site example: http://www.codesampler.com/dx9src/dx9src_6.htm But the code is rather weird: it
This is a rather weird question, so please bear with me. There's a SWF
I'm having a rather weird problem (I think). The user can add a contact

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.