matt.sisto Posted March 22, 2009 Share Posted March 22, 2009 Hello, I have my calendar sorted, and when the user clicks on a day the checkavailability script is activated, but I'm not sure on how I can post the day, month and year from the calendar. Can anyone help? This is my calendar script: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script language="JavaScript"> function win1() { window.open("checkavailability.php","Window1","menubar=no,width=460,height=360,toolbar=no"); } </script> </head> <body> <div align="center"> <?php if ((!isset($_GET["Month"])) && (!isset($_GET["Year"]))) { $Month = date("m"); $Year = date("Y"); } else { $Month = $_GET["Month"]; $Year = $_GET["Year"]; } $Timestamp = mktime(0,0,0,$Month,1,$Year); $MonthName = date("F", $Timestamp); ?> <?php echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\">"; echo "<tr><td colspan=\"7\" align=\"left\">Calendar Table for $MonthName, $Year</td></tr>"; echo "<tr bgcolor=\"#999999\">"; $daysOfWeek = array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); foreach ($daysOfWeek as $value) { echo "<td align=\"center\"><strong><font color=\"#ffffff\">$value</font></strong></td>"; } echo "</tr>"; $MonthStart = date("w", $Timestamp); if ($MonthStart == 0) { // if the month starts on a Sunday $MonthStart = 7; } $LastDay = date("d", mktime(0,0,0,$Month+1, 0, $Year)); $StartDate = -$MonthStart; for ($k=1;$k<=6;$k++){ //print six rows for six possible weeks echo"<tr>"; for ($j=1;$j<=7;$j++){ //seven columns per row $StartDate++; if($StartDate < $LastDay) { //blank calendar space if($StartDate > 0) { echo"<td><a href='javascript:win1()'>$StartDate</a></td> \n"; } else { echo"<td bgcolor=\"#eeeeee\"></td> \n"; } } elseif (($StartDate <=1) && ($StartDate >= $LastDay)) { //date goes here if($StartDate >= 0) { echo"$StartDate</td> \n"; } } } echo"</tr>"; } //End Table Row echo "</table>"; ?> <hr width="200"> <form action="cal.php" accept-charset="UNKNOWN" enctype="application/x-www-form-urlencoded" method="GET" > <?php echo "<select name=\"Month\">"; for($m=1;$m<=12;$m++){ $selected = ""; $longDate = date("F", mktime(0,0,0,$m,1,$Year)); if ($Month==$m){ $selected = "selected "; } echo "<option value=\"$m\" $selected>$longDate</option> \n"; } echo "</select>"; echo "<select name=\"Year\">"; $yeartoday = date(Y); $yearplus1 = date(Y)+1; for($y=$yeartoday;$y<=$yearplus1;$y++){ $selected = ""; $longDate = date("Y", mktime(0,0,0,1,1,$y)); if ($Year==$y){ $selected = "selected \n"; } echo "<option value=\"$y\" $selected>$longDate</option> \n"; } echo "</select>"; ?> <input type="submit" value="go"> </form> </div> </body> </html> and this is my checkavailability script: <?php require "dbconn2.php"; $m = $_POST["month"]; $d = $_POST["day"]; $y = $_POST["year"]; $event_start = $y."-".$m."-".$d." ".$_POST["event_start"]; $sql = "SELECT * FROM calendar_events WHERE event_start = '$event_start'"; $result = mysql_query ($sql, $connection) or die ("Couldn't perform query $sql <br />".mysql_error()); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>List All</title> <script language="JavaScript"> function win2() { window.open("addeventform.php","Window2","menubar=no,width=460,height=360,toolbar=no"); } </script> </head> <body> <legend>List Events <div id="mid"> <table border="1"> <tr> <th align="left">ID </th> <th align="left">Title</th> <th align="left">Short Description</th> </tr> <?php while ($row = mysql_fetch_array($result)) {?> <tr> <td><?=$row['event_id']?></td> <td><?=$row['event_title']?></td> <td><?=$row['event_shortdesc']?></td> </tr> <?php } ?> </table> </div> <div id="left"> <p> <input type="button" onClick="javascript:self.close()" value="close"> <input type="submit" onClick="javascript:win2()" value="Add an Event"></p> </div> </legend> </body> </html> Appreciate any help as always. Link to comment https://forums.phpfreaks.com/topic/150562-post-inputs-from-the-calendar/ Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 erm fek what i just sed i dint read ur code, make some hidden text boxes that you place the data into with php n then submit the form Link to comment https://forums.phpfreaks.com/topic/150562-post-inputs-from-the-calendar/#findComment-790853 Share on other sites More sharing options...
matt.sisto Posted March 22, 2009 Author Share Posted March 22, 2009 Well my code is included in the post but if you go to my calendar you might understand better what I want to do: http://www.salmonsreach.org/cal.php I have written in echo $sql to demonstrate that its not receiving the $d $m $y from the calendar, so it does not retrieve any data from the table calendar_events. ??? Link to comment https://forums.phpfreaks.com/topic/150562-post-inputs-from-the-calendar/#findComment-790856 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 whoa ok, now i really dont get what you are trying to do lol from what i understand you want to submit the day month and year from the calendar when you click on a date correct? Link to comment https://forums.phpfreaks.com/topic/150562-post-inputs-from-the-calendar/#findComment-790863 Share on other sites More sharing options...
matt.sisto Posted March 22, 2009 Author Share Posted March 22, 2009 Yes that is correct. Link to comment https://forums.phpfreaks.com/topic/150562-post-inputs-from-the-calendar/#findComment-790865 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 right ok i think i understand maybe, use some $_GET['']; instead of post then change the win1() function to add the link with some arguments that are passed, but first how is the day stored in your code as i cant see any specific variable to hold the day, how do you know which day the user has clicked on or is that what you are asking? Link to comment https://forums.phpfreaks.com/topic/150562-post-inputs-from-the-calendar/#findComment-790882 Share on other sites More sharing options...
matt.sisto Posted March 22, 2009 Author Share Posted March 22, 2009 This is one of the issues the day variable. and how do I pass the day, month, and year values to the check availability. So do I need to modify my js function to pass the values? Link to comment https://forums.phpfreaks.com/topic/150562-post-inputs-from-the-calendar/#findComment-790889 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 yes that is exactly what you need to do, you need to modify your js function so that it does something like this function win1(day, month, year) { window.open("checkavailability.php?d=" . day. "m=" . month . "y=" . year,"Window1","menubar=no,width=460,height=360,toolbar=no"); } and then later on echo"<td><a href='javascript:win1(" . $d . ", " . $m . ", " . $y . ")'>$StartDate</a></td> "; where $d $m and $y are day month year respectivley and then in your checkavailability script use $day = $_GET['d'] $month = $_GET['m'] $year = $_GET['y'] but i dont know how your going to grab all of the day month and year information from your calendar script Link to comment https://forums.phpfreaks.com/topic/150562-post-inputs-from-the-calendar/#findComment-790936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.