Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Junior Member
    Join Date
    Nov 2005
    Posts
    10
    Member #
    11976
    I am trying to display events (w/ their descriptions, dates, etc.) by looping through dates and checking the database to see if an event falls on that day. I put the info into a display_block and echo it, but of course only the last item in the loop is contained in the display block. The reason I am not just echoing the info in the loop is because I want this info to be in a specific div. If I try to make the div inline it doesn't seem to recognize it. Plus I don't want the div to be considered inside of the div that is checking for the events and displaying them on a calendar. I have added the snippet of code.
    PHP Code:
    <div id = "calendar">
    <?php

    $days 
    = Array("S""M""T""W""T""F""S");
    echo 
    "<TABLE><tr>\n";
    foreach (
    $days as $day
    {
        echo 
    "<td><strong>$day</strong></td>\n";
    }
    for (
    $count=0$count < (6*7); $count++) 
    {
        
    $dayArray getdate($start);
        if ((
    $count 7) == 0
        {
            if (
    $dayArray['mon'] != $month
            {
                break;
            } 
            else 
            {
                echo 
    "</tr><tr>\n";
            }
        }
        if (
    $count $firstDayArray['wday'] || $dayArray['mon'] != $month)
        {
            echo 
    "<td>&nbsp;</td>\n";
        } 
        else 
        {    
            
    // Select eventId and storeId from the date given    
            
    $chkEvent "SELECT `eventId` , `storeId` FROM `calendar` WHERE `day` = '".$dayArray['mday']."' AND `month` = '$month' AND `year` = '$year' LIMIT 0, 30";
            
    $chkEvent_res mysql_query($chkEvent) or die(mysql_error());

            
    // If there is an event, display
            
    if (mysql_num_rows($chkEvent_res) > 0
            {
                while (
    $ev mysql_fetch_array($chkEvent_res)) 
                {
                    
    $eventId $ev['eventId'];
                    
    $storeId $ev['storeId'];
                    
                    
    // Select name of event from eventId in event table and name of store from storeId in store table
                    
    $getStore "SELECT name, address, phone FROM store WHERE id = '$storeId'"
                    
    $resultStore mysql_query($getStore,$conn) or die(mysql_error());
                    
    $rowS mysql_fetch_array($resultStore);
                    
    $storeName $rowS['name'];
                    
    $storeAddress $rowS['address'];
                    
    $storePhone $rowS['phone'];
                    
                    
    $getEvent "SELECT name, description FROM event WHERE id = '$eventId'"
                    
    $resultEvent mysql_query($getEvent,$conn) or die(mysql_error());
                    
    $rowE mysql_fetch_array($resultEvent);
                    
    $eventName $rowE['name'];
                    
    $eventDesc $rowE['description'];
                    
                    
    $months = Array("January""February""March""April""May",  "June""July""August""September""October""November""December");
                    for (
    $x=1$x <= count($months); $x++) 
                    {    
                        if (
    $x == $month)
                        {
                            
    $currMonth $months[$x-1];
                        }
                    }

                    
    $display_block "<p>";
                    
    $display_block .= "<li><strong>Date:</strong> $currMonth ".$dayArray['mday'].", $year</li>";
                    
    $display_block .= "<li><strong>Event Name:</strong> $eventName </li>";
                    
    $display_block .= "<li><strong>Event Description:</strong> $eventDesc </li>";
                    
    $display_block .= "<li><strong>Store Name:</strong> $storeName </li>";
                    
    $display_block .= "<li><strong>Store Address:</strong> $storeAddress </li>";
                    
    $display_block .= "<li><strong>Store Phone:</strong> $storePhone </li>";
                    
    $display_block .= "</p>";
                    
                    echo 
    "<td STYLE='font-size:18px'><strong>".$dayArray['mday']."</strong></td>\n";                            
                }            
            }
            else
            {
                echo 
    "<td>".$dayArray['mday']."</td>\n";
            }
            
    $start += ADAY;
        }
    }
    echo 
    "</tr></table>";
    ?>
    </div> 
    <div id = "event"> 
    <?php 
    echo "<h2>Events for the month of $currMonth:</h2>";
    echo 
    "$display_block"
    ?> 
    </div>
    </div>

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:02 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com