hosted by liquidweb


Go Back   Web Hosting Talk : Advertising Forums : Software & Scripts Offers & Requests : Software & Scripts Requests : Calendar Script, this one is tricky
Reply

Software & Scripts Requests This forum is intended for requesting softwares and scripts that are legally transferable. Please read the Announcement within before posting. You need 10 (relevant, non-advertising, non-fluff) posts in other forums and 7 days of membership before starting a thread in this forum.
Forum Jump

Calendar Script, this one is tricky

Reply Post New Thread In Software & Scripts Requests Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 01-02-2008, 11:14 AM
Mark226 Mark226 is offline
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` (
  `
idint(11NOT NULL auto_increment,
  `
storeint(11NOT NULL default '0',
  `
sdatedate NOT NULL default '0000-00-00',
  `
stimevarchar(8NOT NULL default '',
  `
capacitysmallint(6NOT NULL default '0',
  `
statuschar(1NOT NULL default '',
  
PRIMARY KEY  (`id`)
ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=122 ;

--
-- 
Dumping data for table `sessions`
--

INSERT INTO `sessionsVALUES(111'2007-11-10''9:00 am'12'0');
INSERT INTO `sessionsVALUES(251'2007-12-04''5:00 PM'12'2');
INSERT INTO `sessionsVALUES(101'2007-11-09''9:00 am'12'0');
INSERT INTO `sessionsVALUES(81'2007-12-04''9:00 am'12'3');
INSERT INTO `sessionsVALUES(681'2008-01-02''5:00 pm'12'');
INSERT INTO `sessionsVALUES(131'2007-11-14''5:00 pm'12'');
INSERT INTO `sessionsVALUES(141'2007-11-15''9:00 am'12'0');
INSERT INTO `sessionsVALUES(151'2007-11-16''5:00 pm'12'2');
INSERT INTO `sessionsVALUES(161'2007-11-17''9:00 am'12'1');
INSERT INTO `sessionsVALUES(171'2007-11-23''5:00 pm'12'');
INSERT INTO `sessionsVALUES(181'2007-11-24''9:00 am'12'');
INSERT INTO `sessionsVALUES(191'2007-11-26''9:00 am'12'');
INSERT INTO `sessionsVALUES(201'2007-11-27''5:00 pm'12'');
INSERT INTO `sessionsVALUES(211'2007-11-28''9:00 am'12'');
INSERT INTO `sessionsVALUES(221'2007-11-29''5:00 pm'12'0');
INSERT INTO `sessionsVALUES(231'2007-11-30''9:00 am'12'1');
INSERT INTO `sessionsVALUES(241'2007-11-28''5:00 pm'12'');
INSERT INTO `sessionsVALUES(261'2007-12-05''9:00 AM'12'1');
INSERT INTO `sessionsVALUES(271'2007-12-06''9:00 AM'12'');
INSERT INTO `sessionsVALUES(281'2007-12-06''5:00 PM'12'0');
INSERT INTO `sessionsVALUES(291'2007-12-07''9:00 AM'12'1');
INSERT INTO `sessionsVALUES(301'2007-12-07''5:00 PM'12'2');
INSERT INTO `sessionsVALUES(311'2007-12-08''9:00 AM'12'1');
INSERT INTO `sessionsVALUES(321'2007-12-10''9:00 AM'12'1');
INSERT INTO `sessionsVALUES(331'2007-12-10''5:00 PM'12'');
INSERT INTO `sessionsVALUES(341'2007-12-11''9:00 AM'12'0');
INSERT INTO `sessionsVALUES(351'2007-12-11''5:00 PM'12'1');
INSERT INTO `sessionsVALUES(431'2007-12-15''9:00 AM'12'');
INSERT INTO `sessionsVALUES(371'2007-12-12''9:00 AM'12'1');
INSERT INTO `sessionsVALUES(381'2007-12-12''5:00 PM'12'2');
INSERT INTO `sessionsVALUES(391'2007-12-13''9:00 AM'12'1');
INSERT INTO `sessionsVALUES(671'2008-01-02''9:00 am'12'');
INSERT INTO `sessionsVALUES(411'2007-12-14''9:00 AM'12'0');
INSERT INTO `sessionsVALUES(421'2007-12-14''5:00 PM'12'1');
INSERT INTO `sessionsVALUES(441'2007-12-17''9:00 AM'12'');
INSERT INTO `sessionsVALUES(451'2007-12-17''5:00 PM'12'');
INSERT INTO `sessionsVALUES(461'2007-12-18''9:00 AM'12'');
INSERT INTO `sessionsVALUES(471'2007-12-18''5:00 PM'12'');
INSERT INTO `sessionsVALUES(481'2007-12-19''9:00 AM'12'1');
INSERT INTO `sessionsVALUES(491'2007-12-19''5:00 PM'12'0');
INSERT INTO `sessionsVALUES(501'2007-12-20''9:00 AM'12'');
INSERT INTO `sessionsVALUES(511'2007-12-21''9:00 AM'12'');
INSERT INTO `sessionsVALUES(521'2007-12-21''5:00 PM'12'');
INSERT INTO `sessionsVALUES(531'2007-12-22''9:00 AM'12'');
INSERT INTO `sessionsVALUES(541'2007-12-26''5:00 PM'12'');
INSERT INTO `sessionsVALUES(551'2007-12-27''9:00 AM'12'');
INSERT INTO `sessionsVALUES(561'2007-12-27''5:00 PM'12'');
INSERT INTO `sessionsVALUES(611'2007-11-19''5:00 PM'12'');
INSERT INTO `sessionsVALUES(581'2007-12-28''9:00 AM'12'2');
INSERT INTO `sessionsVALUES(591'2007-12-28''5:00 PM'12'');
INSERT INTO `sessionsVALUES(601'2007-12-29''9:00 AM'12'1');
INSERT INTO `sessionsVALUES(621'2007-12-20''5:00 PM'12'0');
INSERT INTO `sessionsVALUES(701'2008-01-03''9:00 am'12'');
INSERT INTO `sessionsVALUES(711'2008-01-03''5:00 pm'12'');
INSERT INTO `sessionsVALUES(651'2007-11-20''5:00 PM'12'');
INSERT INTO `sessionsVALUES(661'2007-11-21''9:00 AM'12'');
INSERT INTO `sessionsVALUES(721'2008-01-04''9:00 am'12'');
INSERT INTO `sessionsVALUES(731'2008-01-04''5:00 pm'12'');
INSERT INTO `sessionsVALUES(741'0000-00-00''9:00 am'12'');
INSERT INTO `sessionsVALUES(751'2008-01-05''9:00 am'12'');
INSERT INTO `sessionsVALUES(761'2008-01-07''9:00 am'12'');
INSERT INTO `sessionsVALUES(771'2008-01-08''9:00 am'12'');
INSERT INTO `sessionsVALUES(781'2008-01-08''5:00 pm'12'');
INSERT INTO `sessionsVALUES(791'2008-01-09''9:00 am'12'');
INSERT INTO `sessionsVALUES(801'2008-01-10''9:00 am'12'');
INSERT INTO `sessionsVALUES(811'2008-01-10''5:00 pm'12'');
INSERT INTO `sessionsVALUES(821'2008-01-11''9:00 am'12'');
INSERT INTO `sessionsVALUES(831'2008-01-11''5:00 pm'12'');
INSERT INTO `sessionsVALUES(841'2008-01-12''9:00 am'12'');
INSERT INTO `sessionsVALUES(851'2008-01-14''9:00 am'12'');
INSERT INTO `sessionsVALUES(861'2008-01-14''5:00 pm'12'');
INSERT INTO `sessionsVALUES(871'2008-01-15''9:00 am'12'');
INSERT INTO `sessionsVALUES(881'2008-01-15''9:00 am'12'');
INSERT INTO `sessionsVALUES(891'2008-01-15''5:00 pm'12'');
INSERT INTO `sessionsVALUES(901'2008-01-16''9:00 am'12'');
INSERT INTO `sessionsVALUES(911'2008-01-17''9:00 am'12'');
INSERT INTO `sessionsVALUES(921'2008-01-16''1:00 pm'12'');
INSERT INTO `sessionsVALUES(931'2008-01-17''1:00 PM'12'');
INSERT INTO `sessionsVALUES(941'2008-01-18''9:00 AM'12'');
INSERT INTO `sessionsVALUES(951'2008-01-18''5:00 PM'12'');
INSERT INTO `sessionsVALUES(961'2008-01-19''9:00 AM'12'');
INSERT INTO `sessionsVALUES(971'2008-01-21''9:00 AM'12'');
INSERT INTO `sessionsVALUES(981'2008-01-22''9:00 AM'12'');
INSERT INTO `sessionsVALUES(991'2008-01-22''5:00 PM'12'');
INSERT INTO `sessionsVALUES(1001'2008-01-23''9:00 AM'12'');
INSERT INTO `sessionsVALUES(1011'2008-01-23''5:00 PM'12'');
INSERT INTO `sessionsVALUES(1021'2008-01-24''9:00 AM'12'');
INSERT INTO `sessionsVALUES(1041'2008-01-26''9:00 AM'12'');
INSERT INTO `sessionsVALUES(1061'2008-01-07''1:00 PM'12'');
INSERT INTO `sessionsVALUES(1071'2008-01-24''5:00 PM'12'');
INSERT INTO `sessionsVALUES(1081'2008-01-25''9:00 AM'12'');
INSERT INTO `sessionsVALUES(1091'2008-01-25''5:00 PM'12'');
INSERT INTO `sessionsVALUES(1101'2008-01-28''9:00 AM'12'');
INSERT INTO `sessionsVALUES(1111'2008-01-28''5:00 PM'12'');
INSERT INTO `sessionsVALUES(1131'2008-01-29''9:00 AM'12'');
INSERT INTO `sessionsVALUES(1151'2008-01-29''5:00 PM'12'');
INSERT INTO `sessionsVALUES(1161'2008-01-30''9:00 AM'12'');
INSERT INTO `sessionsVALUES(1171'2008-01-30''5:00 PM'12'');
INSERT INTO `sessionsVALUES(1181'2008-01-31''9:00 AM'12'');
INSERT INTO `sessionsVALUES(1191'2008-01-31''5:00 PM'12''); 

Reply With Quote
Sponsored Links
  #2  
Old 01-02-2008, 11:25 AM
speed-frag speed-frag is offline
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

Reply With Quote
  #3  
Old 01-02-2008, 11:33 AM
Mark226 Mark226 is offline
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.

Reply With Quote
Sponsored Links
  #4  
Old 01-02-2008, 11:35 AM
Czaries Czaries is offline
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.

__________________
InvoiceMore - Online Billing & Invoicing
phpDataMapper - Object-Oriented PHP5 Data Mapper ORM

Reply With Quote
  #5  
Old 01-03-2008, 03:13 AM
Mark226 Mark226 is offline
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; 

Reply With Quote
  #6  
Old 01-09-2008, 10:14 AM
mansfield mansfield is offline
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.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
eMetrics Summit Chicago 2013 Web Hosting Events 2013-04-24 17:22:08
Pingdom Talks Top Web Hosting Cities and Countries Web Hosting News 2013-03-27 18:49:54
Web Hosting Sales and Promos Roundup - November 30, 2012 Web Hosting News 2012-11-30 16:23:59
Control Panel cPanel Launches New Apache Configuration Script Web Hosting News 2011-12-28 19:41:39
Email Provider Atmail Releases One-Click iOS Provisioning with Atmail 6.3 Web Hosting News 2011-11-28 20:34:19


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?