Jump to content

aspekt9

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

aspekt9's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I use a calendar script, Keith Deven's PHP Calendar. I've modified it to incorporate events into it and everything works great. The problem I'm having trouble with is when I print the year long calendar. For some reason it only reads the dates in the database for the current month, in this case March and it outputs the same days for every single month. I don't understand how I can fix this. The code displaying the year long calendar is: include 'calendarparent.php'; include 'config.php'; $today = date('j',$time); $month = date('n'); $year = date('Y'); $events = mysql_query("SELECT *, DATE_FORMAT(date, '%M %e, %Y %h:%m:%s') as date, DATE_FORMAT(date, '%c') as month, DATE_FORMAT(date, '%e') as day FROM calevents order by date desc") or die(mysql_error()); if($events) { $days = array(); while($row = mysql_fetch_array($events)) { if($row['month'] == $month) { $day = $row['day']; $days[$day] = array('events.php?action=view&id='.$row['id'], 'linked-day'); } } } echo "<table style=\"margin: auto\"width=450>"; echo "<tr>"; for($month=1; $month<=12; $month++) { echo "<td style=\"vertical-align: top\">"; echo parent_calendar($year, $month, $days,2); echo "<br /></td>"; if($month%3 == 0 and $month<12){ echo "</tr><tr>"; } } echo "</tr>"; echo "</table>"; I think the problem is: echo parent_calendar($year, $month, $days,2); Which makes sense because $days is retrieved from the database if it is equal to the current month, but how can I change this so each date prints to the correct month and day?
  2. I'm looking to create drop down boxes for a user to select the date and then have it insert what they select for month, day, year, hour, minutes and insert it into mysql. It needs to be organized in a timestamp like so: 2007-02-28 21:06:40 I've created the drop down boxes and it works pretty well: function selectCurrentDate($currentMonth, $currentDay, $currentYear, $currentHour, $currentMins, $currentSecs) { $display = ''; // Month Array $monthNames = array('January', 'Feburary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); // MaxNumber of days in a month (will need to write more robust code) $maxDays = 31; // Start year $startYear = 2000; // Display years up to max years $maxYears = 2050; // Max hours to display $maxHour = 12; // Max minutes to display $maxMinutes = 59; // Max seconds to display $maxSeconds = 59; // Begin Month select menu $display .= 'Select event date: <select name="theMonth">'; // Loop through each month foreach ($monthNames as $myMonth) { // If month is equal to $currentMonth passed in, select if($currentMonth == $myMonth) $display .= '<option value="'. $myMonth .'" selected>' . $myMonth . '</option>'; else $display .= '<option value="'. $myMonth .'">' . $myMonth . '</option>'; } // end select $display .= '</select> '; // Begin Day select Menu $display .= ' <select name="theDay">'; // Loop through the max number of days for($i = 1; $i < $maxDays; $i++) { if($i == $currentDay) $display .= '<option value="'. $i .'" selected>'. $i.'</option>'; else $display .= '<option value="'. $i .'">'. $i.'</option>'; } // end day select $display .= '</select>'; // Display year select $display .= ' <select name="theYear">'; // Loop through max number of years for($i = $startYear; $i <= $maxYears; $i++) { if($i == $currentYear) $display .= '<option value="'. $i .'" selected>'. $i.'</option>'; else $display .= '<option value="'. $i .'">'. $i.'</option>'; } $display .= '</select>'; // Begin hour select $display .= ' <select name="theHour">'; for($h = 1; $h <= $maxHour; $h++) { if($h == $currentHour) $display .= '<option value="'. $h .'" selected>'. $h.'</option>'; else $display .= '<option value="'. $h .'">'. $h.'</option>'; } $display .= '</select>'; // Begin minute display $display .= '<select name="theMinutes">'; for($m = 1; $m <= $maxMinutes; $m++) { if($m == $currentMins) $display .= '<option value="'. $m .'" selected>'. $m.'</option>'; else $display .= '<option value="'. $m .'">'. $m.'</option>'; } $display .= '</select>'; // Begin second display $display .= '<select name="theSeconds">'; for($s = 1; $s <= $maxSeconds; $s++) { if($s == $currentSecs) $display .= '<option value="'. $s .'" selected>'. $s.'</option>'; else $display .= '<option value="'. $s .'">'. $s.'</option>'; } $display .= '</select>'; return $display; } $curmonth = date('F'); $curday = date('j'); $curyear = date('Y'); $curhour = date('g'); $curmin = date('i'); $cursecs = date('s'); echo selectCurrentDate($curmonth,$curday,$curyear,$curhour,$curmin,$cursecs); Now how would I organize all the data into a timestamp. Once it's in the form of the timestamp it'll be easy to insert it into mysql. Could I do something like: $events = mysql_query("INSERT INTO timestamp, DATE_FORMAT(date, '%M %e, %Y %h:%m:%s') as something? date, FROM calevents") or die(mysql_error()); I don't really get how the options work Thanks for the suggestions
  3. [code] <html> <body> <form action="login.php?page=submit" method="POST"> Enter your Username: <input type="text" name="uname" /><br> Enter your Email address: <input type="text" name="email" /><br> Enter your Password: <input type="text" name="password" /><br> Enter your First Name: <input type="text" name="firstname" /><br> Enter your Last Name: <input type="text" name="lastname" /><br> <input type="submit value=submit" /> </form> <?php if ($page == "submit") {      if (!isset($name) || $name == " ") {         $error[] = "<b>Error:</b> Username is a required field.";     } if (!isset($pass) || $pass = " ") {     $error[] = "<b>Error:</b> Password is a required field.";     } if (!isset($email) || $email = " ") {         $error[] = "<b>Error:</b> Email address is a required field.";     } if (!isset($firstname) || $firstname = " ") {         $error[] = "<b>Error:</b> First name is a required field.";         } if (!isset($lastname) || $lastname = " ") {         $error[] = "<b>Error:</b> Last name is a required field.";     } if (isset($error)) {         $error = serialize($error);     header("location: ?page=error&error=$error");     die();     }   } if ($page == "error") {           $error = unserialize($error);           foreach ($problem as $error) {                echo $problem."";           }} ?> </body> </html> [/code] can't figure out why it wont work :( any help is greatly appreciated, thanks guys
×
×
  • 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.