Jump to content

How to INSERT Mutiple Dates in MySQL for a calendar


kawasaki

Recommended Posts

I have made a calendar and made files to insert *EVENTS* on given dates. Right now i have it to insert on just a date format date(m - d - Y). What i am trying to figure out how to do is for a user to insert a STARTDATE and ENDDATE in a form and it will insert for all those dates. Maybe multiple entries with each date or a do a STARTDATE and Number of days staying, type deal.

 

Does anyone have the answer of how to accomplish this?

 

The code for adding i have is this


if ( isset($_POST["submit"]) && !empty($event_desc)) {
   $eventyear = $_POST['eventyear'];
   $eventmonth = $_POST['eventmonth'];
   $eventdate = $_POST['eventdate'];
   $day_in_a_mth = date('t', mktime(0, 0, 0, $eventmonth, 1, $eventyear)) ;

if ($day_in_a_mth >= $eventdate )
  {
   $fulldate = $eventyear."-".$eventmonth."-".$eventdate;
   $event_desc = $_POST['event_desc'];

  $sql = "INSERT INTO event SET date='$fulldate', event_desc='$event_desc'";
  $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
  //message( "ADD EVENT", "DATA ENTERED");  
  echo "Your Trout Shack Stay has been added to the calendar. Would you like to add more? <a href='caladd.php'>Add to Calendar<a>";
  }
else {
  message( "ERROR", "DATE ENTERED NOT VALID");

  }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.