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");

  }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.