R
E
S
O
U
R
C
E
S
       Home      Products & Services      Contact Us      Links


WebHatchers will design & develop your site for you.
_______________________

Website Menu Heaven: menus, buttons, etc.
_______________________

Send us your questions.
_______________________

site search by freefind
_______________________

HOME
SEO, Google, Privacy
   and Anonymity
Browser Insanity
JavaScript
Popups and Tooltips
Free Website Search
HTML Form Creator
Animation
Buttons and Menus
Counters
Captchas
Image Uploading
CSS and HTML
PHP
AJAX
XPATH
Website Poll
IM and Texting
Databases—MySQL
   or Not MySQL
Personal Status Boards
Content Management
   Systems
Article Content
   Management Systems
Website Directory
   CMS Systems
Photo Gallery CMS
Forum CMS
Blog CMS
Customer Records
   Management CMS
Address Book CMS
Private Messaging CMS
Chat Room CMS
JavaScript Charts
   and Graphs




Free Personal Status Boards (PSB™)

Free Standard Free PSB

Free PSB Pro Version

Free Social PSB

Free Social PSB Plus (with Email)

Free Business PSB

Free Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement



Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

MC Scheduler Management—Set Up MC Scheduler People

This script is called Setup-Scheduler.php

The MC Scheduler is a caregiving scheduler for kids and/or elders. It contains the application utilities listed above. There is a utility called Setup Scheduler which lets you enter the names of the kids and/or elders needing care. Then it saves 3 files, one with the names of the care needers, one with the names of the caregivers, and one with a blank 2-week schedule.

Before you use the Edit MC Scheduler option on the main menu, you'll need to get everyone together and figure out the caregiving schedule which lasts two weeks, so you'll need to figure out who cares for whom. You'll see that the schedules are set up as half hour slots and cover 24 hours a day. When you first see the schedule it will be set up with two X characters for all slots for the whole two weeks. X means "no care needed." For most MCs or families or groups (or even babysitting co-ops), the slots from 9 p.m. to 7 a.m. will be left with the Xs (parents are "watching over" their kids by sleeping in their own rooms—but still available), so you'll need to set up caregivers for 7 in the morning to 9 at night, mostly, since after that we assume the kids and care-needing elders will be asleep. Of course, also in the daytime will be Xs for when kids are at school or soccer practice or music lessons or preschool or whatever. So even if kids are sleeping over at a different home in your group, it is assumed there are parents sleeping in a nearby room, available as needed.

The reason there are Xs over Xs and—once you fill in the slots—names over names, is that the primary caregiver is on top and the secondary caregiver is on the bottom. See Why Register for an MC? to see why caregiver choice is important—the kid should be able to choose which of these two people will care for him/her. The kid starts with the primary caregiver and chooses to switch to the secondary caregiver if he wants to. The best place for the caregiving is a space set aside for it. This allows kids to play with other kids in their group, and the chosen (primary or secondary) caregiver will be there, playing with or talking with the kids as they wish or—more often—reading a book or doing something on a computer while the kids play together.

The editing of the schedule is simple. Select one of the caregivers from the dropdown menu in Edit MC Scheduler, and click him or her wherever appropriate on the schedule either on top, as the primary caregiver or on the bottom as the secondary caregiver. Do this for the whole two weeks and then go on to the next caregiver from the dropdown menu, until all slots are filled as needed. Yes, the first scheduling meeting will be a long one. Bring snacks!

Even though we designed the Scheduler for MCs (microcommunities), there would be nothing to stop babysitting co-ops from using it. Most co-ops think in terms of one caregiver for so many kids. The American Academy of Pediatrics and the American Public Health Association recommend child-caregiver ratios of 3:1 for children from birth to 12 months, 4:1 for children from 13 to 30 months, 5:1 for children from 31 to 35 months, 7:1 for 3-year-olds, and 8:1 for 4-year-olds and older. We agree, but feel that there needs to be secondary caregivers as well—for backup. Like we say, the kids should be able to choose which of these two people will care for them.

On to the code: The first section is at the start of the script. First, we use the checkid.php script to ensure that the session id variable is set, and send the user to register-with-captcha.php if it is not. Then we put the session variable 'username' into $U—we will be checking that it is set in a second. Then we define a named constant '_NODIRECTACCESS'. We include the config.php file (in the includes folder) which uses the PHP defined() function to check on this constant. If it is not set, we are thrown out of the config.php file like yesterday's trash.

Next we check if the session variables 'groupname', 'username', and 'userid' are set. If not, we are sent to the login-to-mc.php script. We make sure $U is still equal to the session variable 'username', that it is not an empty string, and that it's at least 6 characters long or . . . you guessed it . . . the login script. We make sure the session id is set and send them away if not.

The reason we are willing to use JavaScript to send visitors away is that none of our scripts will work without it. One cannot register, enter data, get from here to there, etc., in most of our scripts without it. What serious web surfer turns off JavaScript? In case you were not aware, many sites rely totally on JavaScript for menu functioning and some of their scripts. And what about data entry? In case you didn't know it, it is a huge convenience for the user because of the way it does input validation. A good site will validate in JavaScript as well as PHP. When the JavaScript data validation script catches unacceptable input, it can simply send focus to the input box where the bad input happened, the user fixes it, and the script is submitted. But if JavaScript is disabled, the user gets sent to PHP data validation which catches the bad data and sends the user back to the input form to redo all input from scratch. The JavaScript data validation script will not make a user restart, if well written. If you have experienced restarting data entry in a long form due to an accidental character, you know exactly what we are talking about. It's maddening! And a good way to get users to surf away from your site forever. If a person turns off THE major browser scripting language just because of a miniscule chance of encountering a scripting exploit on some web page, rather than installing good anti-spyware and anti-virus software, his Internet experience overall will be greatly diminished. Many sites have no alternatives to their script-enabled navigation, so the person is 100% screwed on those sites. But even on those with the alternative, it is always cumbersome and awkward. Besides, the scheduler editing script requires AJAX which in turn needs JavaScript, and if you cannot edit the schedule, it's useless. Point taken?

Next, we determine if the scheduler for this user's group already exists. See test if a mysql table exists. Please note that the user name is joined together with "_scheduler" by use of the concatenation operator, a dot (.). This is so the database can support lots of schedulers since they will have unique names.

Then we create the tables needed for the scheduler: one is the scheduler itself and the other two are just the kid's names and the adult's names. The latter are the caregivers. Note that the scheduler supports 99 kids and 99 adults. MCs or families or groups (or even babysitting co-ops) will mostly need way less space allotment than this, but in case groups combine or at least join forces for caregiving, we set it up to support 99.

In the table, the N field will get 1 through 700 stuck into it since the table has 700 records. Each day of the 2 weeks of the schedule gets 50 records. The first 48 are the time slots and caregivers, the next record has the day of the week, and the 50th record gets the date. A day has 48 half hours and the Time field gets the labels (e.g., "12:00a.m."). And the Day field gets 1 for the 1st day of the schedule for all 50 records. The last day gets 14, since the schedule gets 2 weeks: this week and next week, so you can plan ahead. This field helps with page display—there are 14 day links at the top of each schedule page, and only one page is displayed at once. Note that there are arrays full of the values the scheduler will need and these are inserted into the table using MySQL's INSERT INTO statement. As mentioned, when you first see the schedule after creating it, it will be set up with two X characters for all slots for the whole two weeks. X means "no care needed." Once you enter caregiver names in slots where care is needed, you'll just stick them on top of the Xs, replacing them. The MySQL UPDATE statement is used to stick the days of the week into the table.

Now we use PHP POST to check if the form has been submitted. POST is a 'superglobal', or automatic global, variable that precludes one from needing to declare global in functions, since it is available anywhere in the script. The form will have put the people names into array by use of our AddFormFields and AddFormFields2 functions which create the input boxes on the fly, while the CreateFormTextInput and CreateFormTextInput2 functions put the names you input into these arrays. Tricky stuff. But it works.

We now use POST again to look at the number of people you've put into the form and if you've exceeded 99, the page reloads. This is a great example of the discussion above about the need for JavaScript. In the first place, how could one create form input boxes on the fly without it? And wouldn't it be nasty to type in 123 names and then have the page reload instead of putting them in the MySQL tables? Happily, when getting the number of kids or adults, only 2 characters are allowed, so you cannot add more than 99 anyway. We use maxlength="2" in the number input box. If you found a way to avoid this attribute by avoiding JavaScript, you'd get no input boxes, but if you found a way to get boxes without JavaScript (impossible?) and loaded 666 boxes with names, the PHP input filter would reload the page, after a stern lecture.

Next we create the tables to hold the names using CREATE TABLE IF NOT EXISTS. Then we put the names, POSTed into PHP from the form, into PHP arrays and clean the arrays of any duplicate names by using the array_keys(array_flip($myArray)) trick, which avoids any problems with the flakey array_unique function, and if we find duplicates we tell the user. Now we insert the names into the tables.

Next, due to our on-the-fly form input box creation, let us stop a Return from submitting the form (see jscheuer1's post). Now we validate the name input in JavaScript. It needs to be from 5 to 30 characters and contain only letters and spaces and numbers, although numbers are dumb name components IMHO. Next come the form validation functions that make sure you have entered the number of kids and adults you want before submission is allowed.

In a form where the user inputs a number to represent the number of people he wants to add to a MySQL database table, we have no way to know ahead of time how many people he will want, therefore we cannot prepare the INPUT boxes ahead of time. So we do it on the fly, but not with document.write scripts. We use DOM functions to stick the INPUT boxes we create into the document legitimately, to give the code the very best chance of succeeding in the most browsers. So createElement, setAttribute, and appendChild are utilized.

The function AddFormFields() adds form fields to the form dynamically, using var a = 'adults[]'; a = a.toString(); to name the input box an array element so the input will fill the array elements with content. Note that the appendChild() method puts a break before the next input box, so the boxes end up in a column. The CreateFormTextInput() function uses formField.onblur=function(){validate2(this);}; to validate the input it gets as soon as the input box is exited. Note that it sets input box attributes using the setAttribute method.

The form tells us to Enter numbers next to both "Add adults to MC Scheduler" and "Add kids to MC Scheduler," buttons, then click the top button and add adults, then click the bottom button and add kids. Finally, press the "submit" button. Submit is last, since it will do no good to submit without entering names first.

This script below is called Setup-Scheduler.php


<?php
include_once"checkid.php";
$U=$_SESSION['username'];
define('_NODIRECTACCESS', TRUE);
include_once"includes/config.php";
if (!isset($_SESSION['groupname']) || !isset($_SESSION['userid']) || !isset($_SESSION['username']) || $_SESSION['username']<>$U || !isset($U) || $U=="" || strlen($U)<6 || !isset($_SESSION['sessionid'])){echo '<script language="javascript">alert("Please login, then select MC Scheduler."); window.location = "login-to-mc.php";</script>';}

$a=$U."_scheduler";

$exists = mysql_query("SHOW TABLES LIKE '$a'") or die(mysql_error());
$num_rows = mysql_num_rows($exists);
if($num_rows==0){

$sql = "CREATE TABLE IF NOT EXISTS $a (
id int(4) NOT NULL AUTO_INCREMENT,
N int(4) NOT NULL,
Day int(4) NOT NULL,
Time varchar(10) NOT NULL,
kid1 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid2 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid3 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid4 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid5 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid6 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid7 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid8 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid9 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid10 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid11 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid12 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid13 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid14 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid15 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid16 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid17 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid18 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid19 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid20 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid21 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid22 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid23 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid24 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid25 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid26 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid27 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid28 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid29 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid30 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid31 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid32 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid33 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid34 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid35 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid36 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid37 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid38 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid39 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid40 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid41 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid42 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid43 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid44 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid45 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid46 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid47 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid48 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid49 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid50 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid51 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid52 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid53 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid54 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid55 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid56 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid57 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid58 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid59 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid60 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid61 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid62 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid63 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid64 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid65 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid66 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid67 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid68 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid69 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid70 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid71 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid72 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid73 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid74 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid75 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid76 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid77 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid78 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid79 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid80 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid81 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid82 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid83 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid84 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid85 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid86 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid87 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid88 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid89 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid90 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid91 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid92 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid93 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid94 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid95 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid96 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid97 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid98 varchar(64) NOT NULL DEFAULT 'X<BR>X',
kid99 varchar(64) NOT NULL DEFAULT 'X<BR>X',
PRIMARY KEY (id)
) ENGINE=MyISAM AUTO_INCREMENT=1";

// Execute query
mysql_query($sql);

$Day=array("1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1",
"1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1",
"1","1","1","1","1","1","1","1","1","1","1","1","1","1","2","2","2","2",
"2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2",
"2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2",
"2","2","2","2","2","2","2","2","2","2","3","3","3","3","3","3","3","3",
"3","3","3","3","3","3","3","3","3","3","3","3","3","3","3","3","3","3",
"3","3","3","3","3","3","3","3","3","3","3","3","3","3","3","3","3","3",
"3","3","3","3","3","3","4","4","4","4","4","4","4","4","4","4","4","4",
"4","4","4","4","4","4","4","4","4","4","4","4","4","4","4","4","4","4",
"4","4","4","4","4","4","4","4","4","4","4","4","4","4","4","4","4","4",
"4","4","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5",
"5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5",
"5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","6","6",
"6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6",
"6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6","6",
"6","6","6","6","6","6","6","6","6","6","6","6","7","7","7","7","7","7",
"7","7","7","7","7","7","7","7","7","7","7","7","7","7","7","7","7","7",
"7","7","7","7","7","7","7","7","7","7","7","7","7","7","7","7","7","7",
"7","7","7","7","7","7","7","7","8","8","8","8","8","8","8","8","8","8",
"8","8","8","8","8","8","8","8","8","8","8","8","8","8","8","8","8","8",
"8","8","8","8","8","8","8","8","8","8","8","8","8","8","8","8","8","8",
"8","8","8","8","9","9","9","9","9","9","9","9","9","9","9","9","9","9",
"9","9","9","9","9","9","9","9","9","9","9","9","9","9","9","9","9","9",
"9","9","9","9","9","9","9","9","9","9","9","9","9","9","9","9","9","9",
"10","10","10","10","10","10","10","10","10","10","10","10","10","10",
"10","10","10","10","10","10","10","10","10","10","10","10","10","10",
"10","10","10","10","10","10","10","10","10","10","10","10","10","10",
"10","10","10","10","10","10","10","10","11","11","11","11","11","11",
"11","11","11","11","11","11","11","11","11","11","11","11","11","11",
"11","11","11","11","11","11","11","11","11","11","11","11","11","11",
"11","11","11","11","11","11","11","11","11","11","11","11","11","11",
"11","11","12","12","12","12","12","12","12","12","12","12","12","12",
"12","12","12","12","12","12","12","12","12","12","12","12","12","12",
"12","12","12","12","12","12","12","12","12","12","12","12","12","12",
"12","12","12","12","12","12","12","12","12","12","13","13","13","13",
"13","13","13","13","13","13","13","13","13","13","13","13","13","13",
"13","13","13","13","13","13","13","13","13","13","13","13","13","13",
"13","13","13","13","13","13","13","13","13","13","13","13","13","13",
"13","13","13","13","14","14","14","14","14","14","14","14","14","14",
"14","14","14","14","14","14","14","14","14","14","14","14","14","14",
"14","14","14","14","14","14","14","14","14","14","14","14","14","14",
"14","14","14","14","14","14","14","14","14","14","14","14");

$Time=array("12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ","12:00a.m.","12:30a.m.","1:00a.m.","1:30a.m.","2:00a.m.","2:30a.m.",
"3:00a.m.","3:30a.m.","4:00a.m.","4:30a.m.","5:00a.m.","5:30a.m.",
"6:00a.m.","6:30a.m.","7:00a.m.","7:30a.m.","8:00a.m.","8:30a.m.",
"9:00a.m.","9:30a.m.","10:00a.m.","10:30a.m.","11:00a.m.","11:30a.m.",
"12:00p.m.","12:30p.m.","1:00p.m.","1:30p.m.","2:00p.m.","2:30p.m.",
"3:00p.m.","3:30p.m.","4:00p.m.","4:30p.m.","5:00p.m.","5:30p.m.",
"6:00p.m.","6:30p.m.","7:00p.m.","7:30p.m.","8:00p.m.","8:30p.m.",
"9:00p.m.","9:30p.m.","10:00p.m.","10:30p.m.","11:00p.m.","11:30p.m.", " "," ");

$a=$U."_scheduler";

for($i=0;$i<700;$i++){
$b=$Day[$i];$c=$Time[$i];
$j= $i + 1;
mysql_query("INSERT INTO $a (N, Day, Time)
VALUES('$j','$b','$c')");
}

mysql_query("UPDATE $a SET Time='Sunday' WHERE N='49' OR N='399'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='Monday' WHERE N='99' OR N='449'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='Tuesday' WHERE N='149' OR N='499'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='Wednesday' WHERE N='199' OR N='549'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='Thursday' WHERE N='249' OR N='599'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='Friday' WHERE N='299' OR N='649'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='Saturday' WHERE N='349' OR N='699'") or die(mysql_error());
}

if(isset($_POST['submit'])){

$numa=$_POST['numa'];if($numa>99){echo '<script language="javascript">alert("Please enter only 99 adults."); window.location = "Setup-Scheduler.php";</script>';}

$numk=$_POST['numk'];if($numk>99){echo '<script language="javascript">alert("Please enter only 99 kids."); window.location = "Setup-Scheduler.php";</script>';}

$a=$U."_adults";

$sql = "CREATE TABLE IF NOT EXISTS $a (
id int(4) NOT NULL auto_increment,
N int(4) NOT NULL,
username varchar(30) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM AUTO_INCREMENT=1";

// Execute query
mysql_query($sql);

$a=$U."_kids";

$sql = "CREATE TABLE IF NOT EXISTS $a (
id int(4) NOT NULL auto_increment,
N int(4) NOT NULL,
username varchar(30) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM AUTO_INCREMENT=1";

// Execute query
mysql_query($sql);

$numa=$_POST['numa'];$numk=$_POST['numk'];

$myArray=array();$myArray1=array();
$a=$U."_adults";

for($i=0;$i<$numa;$i++){
array_push ($myArray, $_POST['adults'][$i]);
}
$myArray1=array_keys(array_flip($myArray));//array_unique has BUG!
$c=count($myArray1);
if($numa>$c){echo '<script language="javascript">alert("One or more duplicate names were deleted.");</script>';}

for($i=0;$i<$c;$i++){
$b=$myArray1[$i];
$j= $i + 1;
mysql_query("INSERT INTO $a (N, username)
VALUES('$j','$b')");
}

$myArray2=array();$myArray3=array();
$a=$U."_kids";

for($i=0;$i<$numk;$i++){
array_push ($myArray2, $_POST['kids'][$i]);
}
$myArray3=array_keys(array_flip($myArray2));//array_unique has BUG!
$c2=count($myArray3);
if($numk>$c2){echo '<script language="javascript">alert("One or more duplicate names were deleted.");</script>';}

for($i=0;$i<$c2;$i++){
$b=$myArray3[$i];
$j= $i + 1;
mysql_query("INSERT INTO $a (N, username)
VALUES('$j','$b')");
}

}

mysql_close();

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Set Up MC Scheduler</title>
<meta name="description" content="Set Up MC Scheduler">
<meta name="keywords" content="Set Up MC Scheduler,MC,MC Scheduler">

<script language="javascript">

document.onkeydown = function(e){
e = e? e : window.event;
var k = e.keyCode? e.keyCode : e.which? e.which : null;
if (k == 13){
if (e.preventDefault) e.preventDefault();
return false;}
return true;}

var flag=0;var flag2=0;var clicka=0;var clickk=0;

function validate(field){

var ck_userfirstname = /^[A-Za-z0-9 ]{5,30}$/;
if (field.value.search(ck_userfirstname)==-1)
{field.value='';alert("Please only enter letters and spaces for user names, and enter 5 to 30 characters.");};flag=flag+1;}

function validate2(field){

var ck_userfirstname2 = /^[A-Za-z0-9 ]{5,30}$/;
if (field.value.search(ck_userfirstname2)==-1)
{field.value='';alert("Please only enter letters and spaces for user names, and enter 5 to 30 characters.");};flag2=flag2+1;}

function validateit(){

if(clicka==0||clicka<num_adults){alert("Please enter number of adults to add.");return false}

if(clickk==0||clickk<num_kids){alert("Please enter number of kids to add.");return false}

if(flag==0 || flag2==0){alert("Please only enter letters and spaces for user names, and enter 5 to 30 characters.");return false}

return true;}

var num_adults=0;var num_kids=0;

function CreateFormTextInput (its_name,t) {
var formField = document.createElement ("input");
formField.setAttribute ('type', 'text');
formField.setAttribute ('value', "");
formField.setAttribute ('name', its_name);
formField.setAttribute ('size', '30');
formField.setAttribute ('maxlength', '30');
formField.style.cssText = 'position:absolute;left:5px;top:'+t+'px;';
formField.onblur=function(){validate(this);};
e = document.getElementById("form");
z=t+26;
e.style.height=z+"px";
return formField;
}

function CreateFormTextInput2 (its_name,t) {
var formField = document.createElement ("input");
formField.setAttribute ('type', 'text');
formField.setAttribute ('value', "");
formField.setAttribute ('name', its_name);
formField.setAttribute ('size', '30');
formField.setAttribute ('maxlength', '30');
formField.style.cssText = 'position:absolute;left:355px;top:'+t+'px;';
formField.onblur=function(){validate2(this);};
e = document.getElementById("form");
z=t+26;
e.style.height=z+"px";
return formField;
}

function AddFormFields (num_adults){
for(i=0;i<num_adults;i++){
var d= 130+(i*22);
var a = 'adults[]'; a = a.toString();
var textBox = CreateFormTextInput(a,d);
var br = document.createElement("br");
document.peopleForm.appendChild(br);
document.peopleForm.appendChild(textBox);}}

function AddFormFields2 (num_kids){
for(i=0;i<num_kids;i++){
var d= 130+(i*22);
var a = 'kids[]'; a = a.toString();
var textBox = CreateFormTextInput2(a,d);
var br = document.createElement("br");
document.peopleForm.appendChild(br);
document.peopleForm.appendChild(textBox);}}


Netscape=(navigator.appName.indexOf("Netscape") != -1)

function fix(){if(Netscape){e=document.getElementById('side');e.style.width='122px';}}

</script>

</head>

<body onload='fix()'>
<div style='position:absolute;margin:0 0 0 150px'>
<form name="peopleForm" id='form' method="post" onsubmit="return validateit()" action="Setup-Scheduler.php" style='background-color:#ccc;border:4px solid blue;width:700px;'>
<table width="600" border="1" align="center">
<? echo '<tr><td colspan="2" align="center" style="font-weight:bold;color:blue">Set Up MC Scheduler, '.$U.'</td></tr>'; ?>
<tr>
<td>Number of adults to add:</td>
<td><input name="numa" type="text" id="numa" size=2" maxlength="2" value=''><input type="button" value="Add adults to MC Scheduler" onclick="clicka=1;AddFormFields(document.peopleForm.numa.value)"></td>
</tr>
<tr>
<td>Number of kids to add:</td>
<td><input name="numk" type="text" id="numk" size="2" maxlength="2" value=''><input type="button" value="Add kids to MC Scheduler" onclick="clickk=1;AddFormFields2(document.peopleForm.numk.value)"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input name="submit" type="submit" id="submit" value="submit">
</label> as Administrator of a MC.</td>
</tr>
</table>
</form>
</div>
<div id='side' style='padding:12px;background-color:#eee;border:1px solid black;width:140px;margin:0'>Enter numbers next to both "Add adults to MC Scheduler" and "Add kids to MC Scheduler," buttons, then click the top button and add adults, then click the bottom button and add kids. Finally, press the "submit" button.<BR><a HREF="http://www.thebiganswer.info/MC-Scheduler.php">Return to Scheduler Management</a>.</div>
</body>
</html>