SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Wizard edshuck's Avatar
    Join Date
    Jul 2000
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is an interesting problem and others may have the same. I have an entertainment section on my site. It is a mixed bag of things, plays (date to date), gigs (single date and time), lessons (on going). Looking at http://www.noevalley.com and clicking on entertainment will provide two listings, one for piano and one for magic. it is running off old code because this cannot recognize the date structures.

    The goal is to provide the one of three structures in the output. Date and Time, Start Date End Date, or Ongoing.


    A mini-guide: topa is the top part of the page. Header, menu and the start of the col for the body.
    bottoma is the bottom of the page. close col for body and contains the right col stuff.

    Any help appreciated. Thanks

    <?php
    include("topa.php3"); ?>
    <table><tr><td width="440">
    <center>
    <?php
    PrintTitle3("Current Entertainment Listings");
    ?>
    </center><br>
    <?php
    include("location of my database.inc");
    $Today=date("Y-m-d");
    echo("<center>");
    PrintTitle3b(rawurldecode("$class"));
    echo("</center><BR>");

    $query = "SELECT *
    FROM entertainment
    WHERE ent_category = '$class'
    AND start >= DATE_SUB('$Today', INTERVAL 15 DAY)
    AND ( end >= '$Today'
    OR duration = 'on_going'
    OR duration = 'single_date' )
    GROUP BY ent_category
    ORDER BY ent_category asc";

    $result= mysql_query($query)
    or die ("Cannot execute query A");

    while($row= mysql_fetch_array($result))
    {
    $duration=$row["duration"];
    $event_name=$row["event_name"];
    $event_loc=$row['event_loc'];
    $event_add=$row['event_add'];
    $event_phone=$row['event_phone'];
    $start=$row['start'];
    $end=$row['end'];
    $time=$row['time'];
    $message=$row['message'];

    echo('<table><tr><td align="left" width="220"><b>');
    PrintTitle3l(rawurldecode("$event_name"));
    echo("</b></td>");

    echo('<td align="right" width="220"><b>');
    PrintTitle3l("$event_loc");
    echo("</b></td></tr>");

    echo('<tr><td align="left"><B>');
    PrintTitle3l("$event_add");
    echo("</B></td>");

    echo('<td align="right"><B>');
    PrintTitle3l("$event_phone");
    echo("</B></td></tr>");

    if ($duration=="single_date")
    {
    echo "<tr><td>";
    PrintTitle3b("Date: $start");
    echo "</td><td>";
    PrintTitle3b("Time: $time");
    echo "</td></tr></table>";
    }

    elseif ($duration=="multiple_date")
    {
    echo "<tr><td>";
    PrintTitle3b("Date: $start");
    echo "</td><td>";
    PrintTitle3b("Date: $end");
    echo "</td></tr></table>";
    }

    else
    {
    echo "<tr><td>";
    PrintTitle3b("On Going Event");
    echo "</td><td></td></tr></table>";
    }

    $message=eregi_replace(
    "\[L]([-_./a-zA-Z0-9!&%#?,'=:~]+)\[EL]",
    "<A HREF=\"\\1\">\\1</A>", $message);

    $message=eregi_replace(
    "\[L=([-_./a-xA-Z0-9!&%#?,'=:~]+)]" .
    "([-_./a-xA-Z0-9!&%#?,'=:~]+)\[EL]",
    "<A HREF=\"\\1\">\\2</A>", $message);
    echo($message);

    echo('<HR WIDTH="200" ALIGN="Center" SIZE="2">');
    }
    //query the db
    $query = "SELECT ent_category, count(*) AS num_category
    FROM entertainment
    WHERE duration="on_going"
    OR (start >= DATE_SUB('$Today', INTERVAL 15 DAY)
    AND end >= "$Today")
    OR (duration = "single_date" AND start >= DATE_SUB('$Today', INTERVAL 15 DAY)
    GROUP BY ent_category
    ORDER BY ent_category asc";

    $result= mysql_query($query)
    or die ("Cannot execute query B");
    //print the data in row, field and interate
    // Display the catagories in one or more rows as needed.
    echo('These categories contain current listings: <br>' );
    while ( $row = mysql_fetch_array($result))
    {
    $ent_category=$row["ent_category"];
    $num_category=$row["num_category"];
    echo('<A HREF="ent_2.php4?class=' . $ent_category . '">');
    PrintTitle3b($ent_category);
    echo("</A>" . " (");
    PrintTitle3b($num_category);
    echo(") <br>");
    }
    echo("<br><br>");
    PrintTitle3l("Click on a category listed above for a complete listing of items available in that category and related information. <P>If your theatre, club or class has information that would be appropriate for this listing, please eMail ");
    ?>
    <A href="mailto:edshuck@noevalley.com">noevalley</A>
    <?php
    echo("</td></tr></table></font>");
    include("bottoma.php3"); ?>
    Last edited by edshuck; Mar 12, 2001 at 12:33.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •