Problem with date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nomad
    Recognized Expert Contributor
    • Mar 2007
    • 664

    Problem with date

    I working on a site for a client where they want a calendar to display all their events that they are planning to have. I have built the calendar but I'm having problems with the event part where chose either am or pm.
    If I chose pm and hit the select button then view the calendar it say am.
    For the db I have event_am varchar(2) should I use emum instead?


    Can someone please help me

    thanks
    nomad
    PS if you need the calendar section please let me know.

    Parse error: syntax error, unexpected T_CONSTANT_ENCA PSED_STRING in C:\Program Files\xampp\htd ocs\23\event.ph p on line 12// note it will be line 7

    here is the code:
    [PHP]
    <body>
    <h1>Show/Add Events</h1>
    <?php
    $conn = mysql_connect(" localhost", "abc", "abc") or die(mysql_error ());
    mysql_select_db ("testDB",$conn ) or die(mysql_error ());

    //add any new event
    if ($_POST[op] == "do") {
    $event_date = $_POST[y]."-".$_POST[m]."-".$_POST[d]." ".$_POST[event_time_hh].":".$_POST[event_time_mm].":00" .$_POST[event_am]." ";

    $insEvent = "INSERT INTO calendar_events VALUES('', '$_POST[event_title]', '$_POST[event_shortdesc]', '$event_date', 'event_am')";
    @mysql_query($i nsEvent) or die(mysql_error ());

    }

    //show events for this day
    $getEvent = "SELECT event_title, event_shortdesc , date_format(eve nt_start, '%l:%i %p') as fmt_date FROM calendar_events WHERE month(event_sta rt) = '$_GET[m]' AND dayofmonth(even t_start) = '$_GET[d]' AND year(event_star t) = '$_GET[y]' ORDER BY event_start";

    $getEvent_res = @mysql_query($g etEvent) or die(mysql_error ());

    if (@mysql_num_row s($getEvent_res ) > 0) {
    while ($ev = @mysql_fetch_ar ray($getEvent_r es)) {
    $event_title = stripslashes($e v['event_title']);
    $event_shortdes c = stripslashes($e v['event_shortdes c']);
    $fmt_date = $ev['fmt_date'];

    $event_txt .= "<P><strong>$fm t_date</strong>: $event_title<br >$event_shortde sc";

    }

    }

    if ($event_txt != "") {
    echo "<P><strong>Tod ay's Events:</strong>
    $event_txt
    <hr noshade width=80%>";
    }

    // show form for adding an event
    echo "<form method=post action=\"$_SERV ER[PHP_SELF]\">
    <P><strong>Woul d you like to add an event?</strong><br>Comp lete the form below and press the submit button to add the event and refresh this window.</p>
    <p><strong>Even t Title:</strong><br>
    <input type=text name=event_titl e size=25 maxlength=25>
    <p><strong>Even t Description:</strong><br>
    <input type=text name=event_shor tdesc size=25 maxlength=255>
    <p><strong>Even t Time (hh:mm):</strong><br>

    <select name=event_time _hh>";
    for ($x=1; $x <= 12; $x++) {
    echo "<option value=\"$x\">$x </option>";
    }
    echo "</select> :

    <select name=event_time _mm>
    <option value=\"00\">00 </option>
    <option value=\"15\">15 </option>
    <option value=\"30\">30 </option>
    <option value=\"45\">45 </option>
    </select>

    <select name=event_am>
    <option value=\"am\">am </option>
    <option value=\"pm\">pm </option>
    </select>

    <input type=hidden name=m value=$_GET[m]>
    <input type=hidden name=d value=$_GET[d]>
    <input type=hidden name=y value=$_GET[y]>
    <input type=hidden name=op value=do>
    <br><br>
    <input type=submit name=submit value=\"Add Event\">
    </form>";
    ?>

    [/PHP]
    Last edited by pbmods; Sep 12 '08, 05:51 PM. Reason: Fixed CODE tags.
  • nomad
    Recognized Expert Contributor
    • Mar 2007
    • 664

    #2
    Never mind folks I figure it out.
    I used timedate and based it on a 24 hour period.
    got rid of the event_am field as well.

    nomad

    Comment

    Working...