
01-02-2008, 11:14 AM
|
|
Web Hosting Master
|
|
Join Date: Jul 2003
Posts: 632
|
|
Calendar Script, this one is tricky
I'm willing to PayPal $20 if anyone can assist with this.
I have a calendar script which shows "dinners sessions" available each day of the month. These sessions are stored in database and output into the calendar. It worked fine in November and December, but once it hit January 1st, my calendar is blank. I hope someone can help as I'm having trouble figuring this one out.
PHP Code:
case "step2":
function sessdetect($date) {
global $sess;
if ($sess[$date] != "") {
$val = explode("[rn]",$sess[$date]);
foreach ($val as $eval) {
if (trim($eval) != "") {
$eval = explode(";",$eval);
// status / capacity
if ($eval[3] == "") {
$eval[3] = 0;
}
@$ratio = round($eval[3] / $eval[2],2);
if ($ratio == "0.00") {
$ratio = 0;
$leftover = '<td width="50" bgcolor="#999999"></td>';
}
else if ($ratio == "1.00") {
$ratio = "50";
$full = 1;
}
else {
$ratio = str_replace("0.","",$ratio);
if (strlen($ratio) == "1") {
$ratio = $ratio."0";
}
$ratio = ceil($ratio/2);
$left = 50 - $ratio;
$leftover = '<td width="'.$left.'" bgcolor="#999999"></td>';
}
if ($full == "1") {
$link = '<a href="#" onClick="alert(\'This session is full\')">';
$link2 = 'onClick="alert(\'This session is full\')"';
}
else {
$link = '<a href="?mode=step3&id='.$eval[0].'">';
$link2 = 'onClick="window.location.href=\'?mode=step3&id='.$eval[0].'\'"';
}
$retval .= $link.$eval[1].'</a><br>
<table width="50" border="1">
<tr style="cursor: pointer;" '.$link2.'><td height="15" width="'.$ratio.'" bgcolor="#AE0083"></td>'.$leftover.'</tr></table><br><br>';
}
}
}
return $retval;
}
$_GET['step'] = 'step2';
if ($_POST) {
unset($_SESSION['state']);
unset($_SESSION['store']);
}
if ($_POST[stores] == "" AND $_SESSION[store] == "") {
$content .= 'Please select your store to continue this order.<br>
<a href="session.htm?mode=step1">Click here</a> to turn back.';
}
else {
$q = mysql_query("SELECT city FROM stores WHERE name='$_POST[stores]'") or die(mysql_error());
$a = mysql_fetch_array($q);
$_SESSION['city'] = $a[city];
if (!$_SESSION['store']) {
$_SESSION['state'] = $_POST[state];
$_SESSION['store'] = $_POST[stores];
}
$source = str_replace('Select your store',"Store Selected: <a href=\"session.htm?mode=step1\"><b>$_SESSION[store], $_SESSION[city], $_SESSION[state]</b></a>",$source);
$content .= '<table width="95%">
<tr><td width="70%" class="stext">When would you like your meal to be prepared?</td>
<td class="stext"><b>Session Capacity</b><br>
<table width="50" border="1">
<tr><td height="15" width="30" bgcolor="#AE0083">
<td width="20" bgcolor="#FFFFFF"></tr></table>
</td></tr></table>
<br>';
// get this month and this year
$month = date("n");
$year = date("Y");
if ($_GET[month] != "next") {
// create a timestamp for this month
$stamp = getdate(mktime(0,0,0,$month,1,$year));
if ($stamp['wday'] == "0") {
$stamp['wday'] = 7;
}
$add = '<div align="right"><img src="images/next.png"> <a href="?mode=step2&month=next">Next month</a></div>';
}
else {
if ($month == "12") {
$month = 1;
$year = $year + 1;
}
else {
$month = $month + 1;
}
// create a timestamp for this month
$stamp = getdate(mktime(0,0,0,$month,1,$year));
if ($stamp['wday'] == "0") {
$stamp['wday'] = 7;
}
$add = '<div align="left"><img src="images/previous.png"> <a href="?mode=step2">Previous month</a></div>';
}
// create months that are 31,30
$thirty = array('4','6','9','11');
$thirtyone = array('1','3','5','7','8','10','12');
$content .= $add.'<table width="99%" border="1" cellspacing="0">
<tr bgcolor="#FF9900">
<td colspan="7" class="stext">
<div align="center"><b>'.$stamp['month'].'</b></div>
</td>
</tr>
<tr bgcolor="#DFDFDF">
<td class="stext" width="14%">
<div align="center">Monday</div>
</td>
<td class="stext" width="14%">
<div align="center">Tuesday</div>
</td>
<td class="stext" width="14%">
<div align="center">Wednesday</div>
</td>
<td class="stext" width="14%">
<div align="center">Thursday</div>
</td>
<td class="stext" width="14%">
<div align="center">Friday</div>
</td>
<td class="stext" width="14%">
<div align="center">Saturday</div>
</td>
<td class="stext" width="14%">
<div align="center">Sunday</div>
</td>
</tr>';
// FIND STORE ID AND FIND SESSIOSN
$a = mysql_fetch_array(mysql_query("SELECT id FROM stores WHERE name='$_SESSION[store]' AND state='$_SESSION[state]'"));
$q = mysql_query("SELECT * FROM sessions WHERE store='$a[id]' AND sdate <= DATE_ADD(CURDATE(),INTERVAL 60 DAY) AND sdate >= DATE_SUB(CURDATE(),INTERVAL 60 DAY) ORDER BY sdate,stime DESC");
while ($a = mysql_fetch_array($q)) {
$x = explode("-",$a[sdate]);
if ($x[2] < 10) {
$x[2] = str_replace('0','',$x[2]);
}
$key = "$x[0]-$x[1]-$x[2]";
$sess[$key] .= "$a[id];$a[stime];$a[capacity];$a[status];[rn]";
}
$content .= '<tr>';
// if its not monday we have some excess days from the previous month
if ($stamp['wday'] != "1") {
// determine the previous month
if ($stamp['mon'] == "1") {
$premon = 12;
$preyear = $stamp['year'] - 1;
}
else {
$premon = $stamp['mon'] - 1;
$preyear = $stamp['year'];
}
$ex = $stamp['wday'] - 2;
if ($premon == "2") {
$init = 28 - $ex;
$final = 28;
}
else {
if (in_array($premon,$thirty)) {
$init = 30 - $ex;
$final = 30;
}
if (in_array($premon,$thirtyone)) {
$init = 31 - $ex;
$final = 31;
}
}
for ($k=$init; $k<=$final; $k++) {
$sdate = "$preyear-$premon-$k";
$content .= '<td class="stext" height="80" valign="top"><b>'.$k.'</b><br>'.sessdetect($sdate).'</td>';
}
}
// end excesss
$z = $stamp['wday'];
$mon = $stamp['mon'];
if ($mon == "2") {
$finali = 28;
}
else {
if (in_array($mon,$thirty)) {
$finali = 30;
}
if (in_array($mon,$thirtyone)) {
$finali = 31;
}
}
for ($y=1; $y<=$finali; $y++) {
$sdate = "$stamp[year]-$mon-$y";
$content .= '<td bgcolor="#EFEFEF" class="stext" height="110" valign="top"><b>'.$y.'</b><br>'.sessdetect($sdate).'</td>';
if ($z == "7") {
$content .='</tr>
<tr>';
$z = 1;
}
else {
$z++;
}
}
if ($z != "1") {
$l = 1;
if($mon == "12") {
$newyear = $stamp[year] + 1;
$newmon = 1;
}
else {
$newyear = $stamp[year];
$newmon = $stamp[mon]+1;
}
for ($t=$z; $t<=7; $t++) {
$sdate = "$newyear-$newmon-$l";
$content .= '<td class="stext" height="80" valign="top"><b>'.$l.'</b><br>'.sessdetect($sdate).'</td>';
$l++;
if ($z == "7") {
$content .= '</tr>';
}
}
}
$content .='</table>';
}
break;
And here is the database:
PHP Code:
CREATE TABLE `sessions` (
`id` int(11) NOT NULL auto_increment,
`store` int(11) NOT NULL default '0',
`sdate` date NOT NULL default '0000-00-00',
`stime` varchar(8) NOT NULL default '',
`capacity` smallint(6) NOT NULL default '0',
`status` char(1) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=122 ;
--
-- Dumping data for table `sessions`
--
INSERT INTO `sessions` VALUES(11, 1, '2007-11-10', '9:00 am', 12, '0');
INSERT INTO `sessions` VALUES(25, 1, '2007-12-04', '5:00 PM', 12, '2');
INSERT INTO `sessions` VALUES(10, 1, '2007-11-09', '9:00 am', 12, '0');
INSERT INTO `sessions` VALUES(8, 1, '2007-12-04', '9:00 am', 12, '3');
INSERT INTO `sessions` VALUES(68, 1, '2008-01-02', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(13, 1, '2007-11-14', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(14, 1, '2007-11-15', '9:00 am', 12, '0');
INSERT INTO `sessions` VALUES(15, 1, '2007-11-16', '5:00 pm', 12, '2');
INSERT INTO `sessions` VALUES(16, 1, '2007-11-17', '9:00 am', 12, '1');
INSERT INTO `sessions` VALUES(17, 1, '2007-11-23', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(18, 1, '2007-11-24', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(19, 1, '2007-11-26', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(20, 1, '2007-11-27', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(21, 1, '2007-11-28', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(22, 1, '2007-11-29', '5:00 pm', 12, '0');
INSERT INTO `sessions` VALUES(23, 1, '2007-11-30', '9:00 am', 12, '1');
INSERT INTO `sessions` VALUES(24, 1, '2007-11-28', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(26, 1, '2007-12-05', '9:00 AM', 12, '1');
INSERT INTO `sessions` VALUES(27, 1, '2007-12-06', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(28, 1, '2007-12-06', '5:00 PM', 12, '0');
INSERT INTO `sessions` VALUES(29, 1, '2007-12-07', '9:00 AM', 12, '1');
INSERT INTO `sessions` VALUES(30, 1, '2007-12-07', '5:00 PM', 12, '2');
INSERT INTO `sessions` VALUES(31, 1, '2007-12-08', '9:00 AM', 12, '1');
INSERT INTO `sessions` VALUES(32, 1, '2007-12-10', '9:00 AM', 12, '1');
INSERT INTO `sessions` VALUES(33, 1, '2007-12-10', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(34, 1, '2007-12-11', '9:00 AM', 12, '0');
INSERT INTO `sessions` VALUES(35, 1, '2007-12-11', '5:00 PM', 12, '1');
INSERT INTO `sessions` VALUES(43, 1, '2007-12-15', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(37, 1, '2007-12-12', '9:00 AM', 12, '1');
INSERT INTO `sessions` VALUES(38, 1, '2007-12-12', '5:00 PM', 12, '2');
INSERT INTO `sessions` VALUES(39, 1, '2007-12-13', '9:00 AM', 12, '1');
INSERT INTO `sessions` VALUES(67, 1, '2008-01-02', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(41, 1, '2007-12-14', '9:00 AM', 12, '0');
INSERT INTO `sessions` VALUES(42, 1, '2007-12-14', '5:00 PM', 12, '1');
INSERT INTO `sessions` VALUES(44, 1, '2007-12-17', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(45, 1, '2007-12-17', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(46, 1, '2007-12-18', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(47, 1, '2007-12-18', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(48, 1, '2007-12-19', '9:00 AM', 12, '1');
INSERT INTO `sessions` VALUES(49, 1, '2007-12-19', '5:00 PM', 12, '0');
INSERT INTO `sessions` VALUES(50, 1, '2007-12-20', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(51, 1, '2007-12-21', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(52, 1, '2007-12-21', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(53, 1, '2007-12-22', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(54, 1, '2007-12-26', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(55, 1, '2007-12-27', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(56, 1, '2007-12-27', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(61, 1, '2007-11-19', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(58, 1, '2007-12-28', '9:00 AM', 12, '2');
INSERT INTO `sessions` VALUES(59, 1, '2007-12-28', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(60, 1, '2007-12-29', '9:00 AM', 12, '1');
INSERT INTO `sessions` VALUES(62, 1, '2007-12-20', '5:00 PM', 12, '0');
INSERT INTO `sessions` VALUES(70, 1, '2008-01-03', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(71, 1, '2008-01-03', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(65, 1, '2007-11-20', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(66, 1, '2007-11-21', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(72, 1, '2008-01-04', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(73, 1, '2008-01-04', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(74, 1, '0000-00-00', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(75, 1, '2008-01-05', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(76, 1, '2008-01-07', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(77, 1, '2008-01-08', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(78, 1, '2008-01-08', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(79, 1, '2008-01-09', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(80, 1, '2008-01-10', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(81, 1, '2008-01-10', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(82, 1, '2008-01-11', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(83, 1, '2008-01-11', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(84, 1, '2008-01-12', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(85, 1, '2008-01-14', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(86, 1, '2008-01-14', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(87, 1, '2008-01-15', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(88, 1, '2008-01-15', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(89, 1, '2008-01-15', '5:00 pm', 12, '');
INSERT INTO `sessions` VALUES(90, 1, '2008-01-16', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(91, 1, '2008-01-17', '9:00 am', 12, '');
INSERT INTO `sessions` VALUES(92, 1, '2008-01-16', '1:00 pm', 12, '');
INSERT INTO `sessions` VALUES(93, 1, '2008-01-17', '1:00 PM', 12, '');
INSERT INTO `sessions` VALUES(94, 1, '2008-01-18', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(95, 1, '2008-01-18', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(96, 1, '2008-01-19', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(97, 1, '2008-01-21', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(98, 1, '2008-01-22', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(99, 1, '2008-01-22', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(100, 1, '2008-01-23', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(101, 1, '2008-01-23', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(102, 1, '2008-01-24', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(104, 1, '2008-01-26', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(106, 1, '2008-01-07', '1:00 PM', 12, '');
INSERT INTO `sessions` VALUES(107, 1, '2008-01-24', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(108, 1, '2008-01-25', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(109, 1, '2008-01-25', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(110, 1, '2008-01-28', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(111, 1, '2008-01-28', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(113, 1, '2008-01-29', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(115, 1, '2008-01-29', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(116, 1, '2008-01-30', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(117, 1, '2008-01-30', '5:00 PM', 12, '');
INSERT INTO `sessions` VALUES(118, 1, '2008-01-31', '9:00 AM', 12, '');
INSERT INTO `sessions` VALUES(119, 1, '2008-01-31', '5:00 PM', 12, '');
|

01-02-2008, 11:25 AM
|
|
Disabled
|
|
Join Date: Dec 2007
Location: Pine Tree State
Posts: 17
|
|
I am no php guru but why do some 2008 dates not have any data in the last ' ' but some 2007's do?
Brandon
|

01-02-2008, 11:33 AM
|
|
Web Hosting Master
|
|
Join Date: Jul 2003
Posts: 632
|
|
Those are used for a different part of the script but doesn't affect this part.
|

01-02-2008, 11:35 AM
|
|
Junior Guru
|
|
Join Date: Aug 2001
Location: Central USA
Posts: 200
|
|
In your SQL query you have this:
PHP Code:
// FIND STORE ID AND FIND SESSIOSN $a = mysql_fetch_array(mysql_query("SELECT id FROM stores WHERE name='$_SESSION[store]' AND state='$_SESSION[state]'"));
I noticed that none of the 2008 dates have anything set in the 'state' field. Your query selects rows based on state='$_SESSION[state]'. You need to find what's in $_SESSION[state] (just print/echo the value) and see if that's causing it. If it's not blank like the 'status' column for all your 2008 dates, those rows won't be a match to the SQL query, and thus won't be returned in the result set.
|

01-03-2008, 03:13 AM
|
|
Web Hosting Master
|
|
Join Date: Jul 2003
Posts: 632
|
|
I got it working. However, there is still one issue. It's only showing sessions which fall into calendar dates 10 through 31. It does not show anything for January 1st, through 9th. Any ideas?
PHP Code:
case "step2":
function sessdetect($date) { global $sess;
if ($sess[$date] != "") { $val = explode("[rn]",$sess[$date]);
foreach ($val as $eval) {
if (trim($eval) != "") { $eval = explode(";",$eval);
// status / capacity if ($eval[3] == "") { $eval[3] = 0; }
@$ratio = round($eval[3] / $eval[2],2);
if ($ratio == "0.00") { $ratio = 0; $leftover = '<td width="50" bgcolor="#999999"></td>'; } else if ($ratio == "1.00") { $ratio = "50"; $full = 1; }
else { $ratio = str_replace("0.","",$ratio);
if (strlen($ratio) == "1") { $ratio = $ratio."0"; } $ratio = ceil($ratio/2); $left = 50 - $ratio; $leftover = '<td width="'.$left.'" bgcolor="#999999"></td>'; }
if ($full == "1") { $link = '<a href="#" onClick="alert(\'This session is full\')">'; $link2 = 'onClick="alert(\'This session is full\')"'; }
else { $link = '<a href="?mode=step3&id='.$eval[0].'">'; $link2 = 'onClick="window.location.href=\'?mode=step3&id='.$eval[0].'\'"'; }
$retval .= $link.$eval[1].'</a><br> <table width="50" border="1"> <tr style="cursor: pointer;" '.$link2.'><td height="15" width="'.$ratio.'" bgcolor="#AE0083"></td>'.$leftover.'</tr></table><br><br>'; } }
}
return $retval; }
$_GET['step'] = 'step2';
if ($_POST) { unset($_SESSION['state']); unset($_SESSION['store']); }
if ($_POST[stores] == "" AND $_SESSION[store] == "") { $content .= 'Please select your store to continue this order.<br> <a href="session.htm?mode=step1">Click here</a> to turn back.'; }
else { $q = mysql_query("SELECT city FROM stores WHERE name='$_POST[stores]'") or die(mysql_error()); $a = mysql_fetch_array($q); $_SESSION['city'] = $a[city];
if (!$_SESSION['store']) { $_SESSION['state'] = $_POST[state]; $_SESSION['store'] = $_POST[stores]; } $source = str_replace('Select your store',"Store Selected: <a href=\"session.htm?mode=step1\"><b>$_SESSION[store], $_SESSION[city], $_SESSION[state]</b></a>",$source);
$content .= '<table width="95%"> <tr><td width="70%" class="stext">When would you like your meal to be prepared?</td> <td class="stext"><b>Session Capacity</b><br>
<table width="50" border="1"> <tr><td height="15" width="30" bgcolor="#AE0083"> <td width="20" bgcolor="#FFFFFF"></tr></table>
</td></tr></table>
<br>';
// get this month and this year $month = date("n"); $year = date("Y");
if ($_GET[month] != "next") { // create a timestamp for this month $stamp = getdate(mktime(0,0,0,$month,1,$year));
if ($stamp['wday'] == "0") { $stamp['wday'] = 7; }
$add = '<div align="right"><img src="images/next.png"> <a href="?mode=step2&month=next">Next month</a></div>'; }
else { if ($month == "12") { $month = 1; $year = $year + 1; }
else { $month = $month + 1; }
// create a timestamp for this month $stamp = getdate(mktime(0,0,0,$month,1,$year));
if ($stamp['wday'] == "0") { $stamp['wday'] = 7; }
$add = '<div align="left"><img src="images/previous.png"> <a href="?mode=step2">Previous month</a></div>'; }
// create months that are 31,30 $thirty = array('4','6','9','11'); $thirtyone = array('1','3','5','7','8','10','12'); $content .= $add.'<table width="99%" border="1" cellspacing="0"> <tr bgcolor="#FF9900"> <td colspan="7" class="stext"> <div align="center"><b>'.$stamp['month'].'</b></div> </td> </tr> <tr bgcolor="#DFDFDF"> <td class="stext" width="14%"> <div align="center">Monday</div> </td> <td class="stext" width="14%"> <div align="center">Tuesday</div> </td> <td class="stext" width="14%"> <div align="center">Wednesday</div> </td> <td class="stext" width="14%"> <div align="center">Thursday</div> </td> <td class="stext" width="14%"> <div align="center">Friday</div> </td> <td class="stext" width="14%"> <div align="center">Saturday</div> </td> <td class="stext" width="14%"> <div align="center">Sunday</div> </td> </tr>';
// FIND STORE ID AND FIND SESSIOSN $a = mysql_fetch_array(mysql_query("SELECT id FROM stores WHERE name='$_SESSION[store]' AND state='$_SESSION[state]'")); $q = mysql_query("SELECT * FROM sessions WHERE store='$a[id]' AND sdate <= DATE_ADD(CURDATE(),INTERVAL 60 DAY) AND sdate >= DATE_SUB(CURDATE(),INTERVAL 60 DAY) ORDER BY sdate,stime DESC");
while ($a = mysql_fetch_array($q)) {
$x = explode("-",$a[sdate]); if ($x[2] < 10) { $x[2] = str_replace('0','',$x[2]); }
$key = "$x[0]-$x[1]-$x[2]";
$sess[$key] .= "$a[id];$a[stime];$a[capacity];$a[status];[rn]"; }
$content .= '<tr>';
// if its not monday we have some excess days from the previous month if ($stamp['wday'] != "1") { // determine the previous month if ($stamp['mon'] == "1") { $premon = 12; $preyear = $stamp['year'] - 1; }
else { $premon = $stamp['mon'] - 1; $preyear = $stamp['year']; }
$ex = $stamp['wday'] - 2; if ($premon == "2") { $init = 28 - $ex; $final = 28; }
else {
if (in_array($premon,$thirty)) { $init = 30 - $ex; $final = 30; }
if (in_array($premon,$thirtyone)) { $init = 31 - $ex; $final = 31; }
}
for ($k=$init; $k<=$final; $k++) { $sdate = "$preyear-$premon-$k"; $content .= '<td class="stext" height="80" valign="top"><b>'.$k.'</b><br>'.sessdetect($sdate).'</td>'; }
} // end excesss
$z = $stamp['wday']; $mon = $stamp['mon'];
if ($mon < 10) { $mon = "0".$mon; }
if ($mon == "02") { $finali = 28; } else { if (in_array($mon,$thirty)) { $finali = 30; }
if (in_array($mon,$thirtyone)) { $finali = 31; }
}
for ($y=1; $y<=$finali; $y++) { if ($y < 10) { $y = "0".$y; }
$sdate = "$stamp[year]-$mon-$y";
$content .= '<td bgcolor="#EFEFEF" class="stext" height="110" valign="top"><b>'.$y.'</b><br>'.sessdetect($sdate).'</td>';
if ($z == "7") { $content .='</tr> <tr>';
$z = 1; }
else { $z++; }
}
if ($z != "1") { $l = 1; if($mon == "12") { $newyear = $stamp[year] + 1; $newmon = 1; } else { $newyear = $stamp[year]; $newmon = $stamp[mon]+1; }
for ($t=$z; $t<=7; $t++) { $sdate = "$newyear-$newmon-$l"; $content .= '<td class="stext" height="80" valign="top"><b>'.$l.'</b><br>'.sessdetect($sdate).'</td>'; $l++; if ($z == "7") { $content .= '</tr>'; }
}
}
$content .='</table>'; }
break;
|

01-09-2008, 10:14 AM
|
|
New Member
|
|
Join Date: Mar 2004
Posts: 2
|
|
PHP Code:
if ($x[2] < 10) { $x[2] = str_replace('0','',$x[2]); }
Why do you have this here? This replaces all your 1-9 day value with 0, resulting in your 1-9 days to be without any data.
Remove this and it will solve your problem.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|