Bazen içeriği yüklemek ve bazen yok

0 Cevap php

I http://cacrochester.com, bazen, bazen sağ kenar çubuğu yükün içeriği ve onlar yok, aşağıda ve web sitesinde komut dosyası var. Ben onu bir sayfadaki ilk birkaç kez ise, hiçbir etkinlik planlanıyor diyecektir olduğunu düşünüyorum.

Ben tamamen bu neden oluyor stumped. Veritabanında veri değişen değildir.

Artık kodunuzu göndermek için bana ihtiyacınız olursa haberim olsun.

Yardım için teşekkürler!

<?php

            $dummy = 0;
            $headingLength = 0;
            $descriptionLength = 0;
            $shortHeading = 0;
            $shortDescription = 0;
            $todayYear = date('Y');
            $todayMonth = date('m');
            $todayDay = date('d');
            $events = new dates();
            $noEvents = 0;

            //get the number of upcoming events
            $numEvents = $events->getNumberEvents();

            //get the actual events
            $results = $events->getRows();

            //used if there are not at least 5 events to fill up the event scroller
            switch($numEvents) {
                case 1: $dummy = 4; break;
                case 2: $dummy = 3; break;
                case 3: $dummy = 2; break;
                case 4: $dummy = 1; break;
            }

            //loops through all of the events in the table and adds them to the list
            foreach($results as $result) 
            {   
                $strippedHeading = stripslashes($result['heading']);
                $strippedDescription = stripslashes($result['description']);
                $headingLength = strlen($strippedHeading);
                $descriptionLength = strlen($strippedDescription);
                $shortHeading = $strippedHeading;
                $shortDescription = $strippedDescription;
                $time = strftime("%l:%M %P", $result['time']);
                $location = $result['location'];
                $startDate = getdate($result['start_date']);
                $today = getdate();

                //if the events are NOT in the past...          
                if($startDate >= $today)
                {       
                    //if we are at the end of the array, add the class 'last' to the li
                    if(current($result) == end($result)) 
                    {
                        echo "<li class=\"last\"><a href=\"Calendar.php\"><h4>".$shortHeading."</h4><h6>$time</h6><h6>$location</h6></a></li>".PHP_EOL;
                    } 
                    else 
                    {
                        echo "<li><a href=\"Calendar.php\"><h4>".$shortHeading."</h4><h6>$time</h6><h6>$location</h6></a></li>".PHP_EOL;
                    }                   
                    $noEvents = 1; 
                }   

                //if there is not at least 5 events, it repeats the events in the list until there are 5 total
                elseif($dummy > 0 && $numEvents > 0) 
                {                   
                    //if the events are NOT in the past...
                    if($startDate >= $today) 
                    {   
                        //if we are at the end of the array, add the class 'last' to the li
                        if($dummy == 0) 
                        {
                            echo "<li class=\"last\"><a href=\"Calendar.php\"><h4>".$shortHeading."</h4> ".$shortDescription."</a></li>".PHP_EOL;  
                            $dummy--;
                        } 
                        else 
                        {
                            echo "<li><a href=\"Calendar.php\"><h4>".$shortHeading."</h4> ".$shortDescription."</a></li>".PHP_EOL;  
                            $dummy--;
                        }

                        //if we have 5 events, do not add anymore
                        if($dummy < 0) 
                        {
                            break;
                        }
                    }

                    $noEvents = 1;
                }  
            }

            //if there are no events, display the no events message
            if($noEvents == 0)
            {
                echo "<li class=\"last\"><a href=\"Calendar.php\"><h4>No Events Scheduled</h4></a></li>".PHP_EOL;  
            }
            ?>

0 Cevap