Annonceindlæg fra HP
29. august 2011 - 12:36
#15
Den der kan svare mig på hvorfor mine hidden fields ikke bliver opdateret, men bare tomme.madplan.php: <html> <head> <title>FoodPlaner</title> <style type="text/css"> .tal { text-align: right; } </style> <script type="text/javascript"> function getNewReceipe(categori, day) { if (categori=="") { return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById(day).innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","newTable.php?q="+categori+"&day="+day,true); xmlhttp.send(); } </script> </head> <body> <?php error_reporting ( 0 ); $including = true; include ('helper.php'); ini_set ( 'default_charset', 'UTF-8' ); ?> <center> <h1>Kal kya pakaye.com</h1> <script language="javascript" type="text/javascript"> function checkIfFeltIsTrue(felt){ if (felt[1].checked == true) { return true; } return false; } </script> <?php if (! isset ( $_POST [ja] ) and ! isset ( $_POST ["vaelgOpskrifter"] ) and (! isset ( $_POST [lockweeksrecepies] ))) { ?> <h2>Lets make our menu</h2> <form name="chooseInterval" method="post" action="<?php print "$_SERVER[PHP_SELF]";?>"> What interval do you want your menu? <br> <br> <table> <tr> <td>Next week<input type="radio" name="interval" value="nextWeek" onclick="document.chooseInterval.includingToday.checked = false"></td> </tr> <tr> <td>Rest of this week<input id="restOfThisWeek" type="radio" name="interval" value="restOfThisWeek"> Including today?<input id= "includingToday" type="checkbox" name="includingToday" onclick="return checkIfFeltIsTrue(document.chooseInterval.elements['interval'])"></td> </tr> <tr> <!-- <td>Just today<input type="radio" name="interval" value="onlyToday"></td> --> </tr> </table> <input type="submit" value="Lets do it!!!" name="ja"> </form> <?php } if (isset ( $_POST [ja] )) { ?> <form method="post" action="<?php print "$_SERVER[PHP_SELF]";?>"> <table border=1> <tbody> <tr> <?php $weekdaysPrint = array ("Monday", "Tuesday", "Wedensday", "Thursday", "Friday", "Saturday", "Sunday" ); $dayOfTheWeek = 0; if ($_POST [interval] == "restOfThisWeek") { $dayOfTheWeek = ( integer ) date ( "w", time () ); if (isset ( $_POST [includingToday] )) { $dayOfTheWeek -= 1; } } if ($_POST [interval] == "onlyToday") { $dayOfTheWeek = 6; $weekdaysPrint [6] = "Today"; } for($optaelling1 = $dayOfTheWeek; $optaelling1 < 7; $optaelling1 ++) { print ("<th>") ; print $weekdaysPrint [$optaelling1]; print ("</th>") ; } ?> </tr> <tr> <?php $receipeCategories = array ("Rice with chicken", "Roti with ghost", "Roti with chicken", "Rice with ghost", "Other", "Weekend", "Day Off" ); $weekdays = array ("monday", "tuesday", "wedensday", "thursday", "friday", "saturday", "sunday" ); for($optaelling = $dayOfTheWeek; $optaelling < 7; $optaelling ++) { print ("<th>") ; print ("<select name=\"$weekdays[$optaelling]\">") ; for($count = 0; $count < 7; $count ++) { print ("<option value=\"" . $receipeCategories [$count]) ; if ($optaelling == $count) { print ("\" SELECTED ") ; } print ("\">" . $receipeCategories [$count]) ; print ("</option>") ; print ("\n") ; } print ("</select>") ; print ("\n") ; print ("</th>") ; } ?> </tr> </tbody> </table> <br> <input type="hidden" name="interval" value="<?php print ($_POST [interval]) ;?>"> <input type="hidden" name="includingToday" value="<?php print ($_POST [includingToday]) ;?>"> <input type="submit" value="ok" name="vaelgOpskrifter"> <br> <br> <input type="button" value="Change your choice" onclick="history.go(-1);return false;" /></form> <?php } ?> <?php if (isset ( $_POST [vaelgOpskrifter] )) { $weeksrecepies = array ($_POST [monday], $_POST [tuesday], $_POST [wedensday], $_POST [thursday], $_POST [friday], $_POST [saturday], $_POST [sunday] ); if (in_array ( "Rice with chicken", $weeksrecepies )) { $Rice_with_chickenArray = getRiceWithChickenArray (); shuffle ( $Rice_with_chickenArray ); } if (in_array ( "Rice with ghost", $weeksrecepies )) { $Rice_with_ghostArray = getRiceWithGhostArray (); shuffle ( $Rice_with_ghostArray ); } if (in_array ( "Roti with chicken", $weeksrecepies )) { $Roti_with_chickenArray = getRotiWithChickenArray (); shuffle ( $Roti_with_chickenArray ); } if (in_array ( "Roti with ghost", $weeksrecepies )) { $Roti_with_ghostArray = getRotiWithGhostArray (); shuffle ( $Roti_with_ghostArray ); } if (in_array ( "Other", $weeksrecepies )) { $OtherArray = getOtherArray (); shuffle ( $OtherArray ); } if (in_array ( "Weekend", $weeksrecepies )) { $WeekendArray = getWeekendArray (); shuffle ( $WeekendArray ); } if (in_array ( "Day Off", $weeksrecepies )) { $DayOffArray = Array(" ", " ", " ", " ", " "," "," "); } ?> <table border=1 width="600"> <tbody> <tr> <th align="center" width="20%">Day to cook</th> <th align="center" width="20%">Type of Dish</th> <th align="center" width="20%">Name of Dish</th> <th align="center" width="20%">Last made</th> <th align="center" width="20%"> </th> </tr> </table> <?php if (($_POST [interval]) != "onlyToday") { ?> <form method="post" action="<?php print "$_SERVER[PHP_SELF]"?>"> <div id="mondayTable"> <table border=1 width="600"> <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'"> <th align="left" width="20%">Monday: </th> <th align="left" width="20%"><?php print ($_POST [monday]);?> </th> <th align="left" width="20%"><?php $mondayArray = ($_POST [monday]); $mondayArray = str_replace ( " ", "_", $mondayArray ); $mondaysdish = array_pop ( ${$mondayArray . 'Array'} ); print ($mondaysdish ['name']) ; ?> </th> <th align="left" width="20%"><?php print ($mondaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ; ?> </th> <?php if ($mondaysdish != null) { ?> <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [monday]);?>','mondayTable')"> </th> <?php } if ($mondaysdish == null) { ?> <th align="left" width="20%"> </th> <?php } ?> </tr> </table> <input type="hidden" value="<?php print ($mondaysdish ['name']);?>" name="monday"> <input type="hidden" value="<?php print ($_POST[monday]);?>" name="mondayCategori"> </div> <div id="tuesdayTable"> <table border=1 width="600"> <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'"> <th align="left" width="20%">Tuesday: </th> <th align="left" width="20%"><?php print ($_POST [tuesday]) ;?> </th> <th align="left" width="20%"><?php $tuesdayArray = ($_POST [tuesday]); $tuesdayArray = str_replace ( " ", "_", $tuesdayArray ); $tuesdaysdish = array_pop ( ${$tuesdayArray . 'Array'} ); print ($tuesdaysdish ['name']) ;?> </th> <th align="left" width="20%"> <?php print ($tuesdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ; ?> </th> <?php if ($tuesdaysdish != null) { ?> <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [tuesday]);?>','tuesdayTable')"> </th> <?php } if ($tuesdaysdish == null) { ?> <th align="left" width="20%"> </th> <?php } ?> </tr> </table> <input type="hidden" value="<?php print ($tuesdaysdish ['name']);?>" name="tuesday"> <input type="hidden" value="<?php print ($_POST[tuesday]);?>" name="tuesdayCategori"> </div> <div id="wedensdayTable"> <table border=1 width="600"> <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'"> <th align="left" width="20%">Wedensday: </th> <th align="left" width="20%"><?php print ($_POST [wedensday]) ;?> </th> <th align="left" width="20%"><?php $wedensdayArray = ($_POST [wedensday]); $wedensdayArray = str_replace ( " ", "_", $wedensdayArray ); $wedensdaysdish = array_pop ( ${$wedensdayArray . 'Array'} ); print ($wedensdaysdish ['name']) ;?> </th> <th align="left" width="20%"><?php print ($wedensdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ; ?> </th> <?php if ($wedensdaysdish != null) { ?> <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [wedensday]);?>','wedensdayTable')"> </th> <?php } if ($wedensdaysdish == null) { ?> <th align="left" width="20%"> </th> <?php } ?> </tr> </table> <input type="hidden" value="<?php print ($wedensdaysdish ['name']);?>" name="wedensday"> <input type="hidden" value="<?php print ($_POST[wedensday]);?>" name="wedensdayCategori"> </div> <div id="thursdayTable"> <table border=1 width="600"> <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'"> <th align="left" width="20%">Thursday: </th> <th align="left" width="20%"><?php print ($_POST [thursday]) ; ?> </th> <th align="left" width="20%"><?php $thursdayArray = ($_POST [thursday]); $thursdayArray = str_replace ( " ", "_", $thursdayArray ); $thursdaysdish = array_pop ( ${$thursdayArray . 'Array'} ); print ($thursdaysdish ['name']) ;?> </th> <th align="left" width="20%"> <?php print ($thursdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ; ?> </th> <?php if ($thursdaysdish != null) { ?> <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [thursday]);?>','thursdayTable')"> </th> <?php } if ($thursdaysdish == null) { ?> <th align="left" width="20%"> </th> <?php } ?> </tr> </table> <input type="hidden" value="<?php print ($thursdaysdish ['name']);?>" name="thursday"> <input type="hidden" value="<?php print ($_POST[thursday]);?>" name="thursdayCategori"> </div> <div id="fridayTable"> <table border=1 width="600"> <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'"> <th align="left" width="20%">Friday: </th> <th align="left" width="20%"><?php print ($_POST [friday]) ; ?> </th> <th align="left" width="20%"><?php $fridayArray = ($_POST [friday]); $fridayArray = str_replace ( " ", "_", $fridayArray ); $fridaysdish = array_pop ( ${$fridayArray . 'Array'} ); print ($fridaysdish ['name']) ; ?> </th> <th align="left" width="20%"><?php print ($fridaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ; ?> </th> <?php if ($fridaysdish != null) { ?> <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [friday]);?>','fridayTable')"> </th> <?php } if ($fridaysdish == null) { ?> <th align="left" width="20%"> </th> <?php } ?> </tr> </table> <input type="hidden" value="<?php print ($fridaysdish ['name']);?>" name="friday"> <input type="hidden" value="<?php print ($_POST[friday]);?>" name="fridayCategori"> </div> <div id="saturdayTable"> <table border=1 width="600"> <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'"> <th align="left" width="20%">Saturday: </th> <th align="left" width="20%"><?php print ($_POST [saturday]) ;?> </th> <th align="left" width="20%"><?php $saturdayArray = ($_POST [saturday]); $saturdayArray = str_replace ( " ", "_", $saturdayArray ); $saturdaysdish = array_pop ( ${$saturdayArray . 'Array'} ); print ($saturdaysdish ['name']) ;?> </th> <th align="left" width="20%"><?php print ($saturdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;?> </th> <?php if ($saturdaysdish != null) { ?> <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [saturday]);?>','saturdayTable')"> </th> <?php } if ($saturdaysdish == null) { ?> <th align="left" width="20%"> </th> <?php } ?> </tr> </table> <input type="hidden" value="<?php print ($saturdaysdish ['name']);?>" name="saturday"> <input type="hidden" value="<?php print ($_POST[saturday]);?>" name="saturdayCategori"> </div> <div id="sundayTable"> <table border=1 width="600"> <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'"> <th align="left" width="20%">Sunday: </th> <th align="left" width="20%"><?php print ($_POST [sunday]) ; ?> </th> <th align="left" width="20%"><?php $sundayArray = ($_POST [sunday]); $sundayArray = str_replace ( " ", "_", $sundayArray ); $sundaysdish = array_pop ( ${$sundayArray . 'Array'} ); print ($sundaysdish ['name']) ; ?> </th> <th align="left" width="20%"><?php print ($sundaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ; ?> </th> <?php if ($sundaysdish != null) { ?> <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [sunday]);?>','sundayTable')"> </th> <?php } if ($sundaysdish == null) { ?> <th align="left" width="20%"> </th> <?php } ?> </tr> </table> <input type="hidden" value="<?php print ($sundaysdish ['name']);?>" name="sunday"> <input type="hidden" value="<?php print ($_POST[sunday]);?>" name="sundayCategori"> </div> <input type="button" value=" <-- Choose other recepies " onclick="history.go(-1);return false;" /> <br> <br> <input type="submit" name="lockweeksrecepies" value="Lock Recepies" onmouseover="this.value='Recepies will be locked for 3 weeks!'" onmouseout="this.value='Lock Recepies'"> </form> <br> <br> <?php } } if (isset ( $_POST [lockweeksrecepies] )) { $message = '<html><body>'; $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $message .= "<tr style='background: #eee;'><td><strong>Day</strong></td><td><strong>Categori</strong></td><td><strong>Dish</strong></td></tr>"; $message .= "<tr><td>Monday:</td><td>".$_POST[mondayCategori]."</td><td>".$_POST[monday]."</td></tr>"; $message .= "<tr><td>Tuesday:</td><td>".$_POST[tuesdayCategori]."</td><td>".$_POST[tuesday]."</td></tr>"; $message .= "<tr><td>Wedensday:</td><td>".$_POST[wedensdayCategori]."</td><td>".$_POST[wedensday]."</td></tr>"; $message .= "<tr><td>Thursday:</td><td>".$_POST[thursdayCategori]."</td><td>".$_POST[thursday]."</td></tr>"; $message .= "<tr><td>Friday:</td><td>".$_POST[fridayCategori]."</td><td>".$_POST[friday]."</td></tr>"; $message .= "<tr><td>Saturday:</td><td>".$_POST[saturdayCategori]."</td><td>".$_POST[saturday]."</td></tr>"; $message .= "<tr><td>Sunday:</td><td>".$_POST[sundayCategori]."</td><td>".$_POST[sunday]."</td></tr>"; $message .= "</table>"; $message .= "</body></html>"; // $headers = "From: Foodplaner\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; mail("tommy.lynge@gmail.com", "Weekmenu", $message, $headers); // weekMenuApproved($_POST[monday], $_POST[tuesday], $_POST[wedensday], $_POST[thursday], $_POST[friday], $_POST[saturday], $_POST[sunday]); print ("Receipes locked!") ; print ("<br>") ; print ("<br>") ; print ("Check apka email for menu") ; print("<br>"); print("<br>"); } ?> </center> </body> </html>newtable.php <?php $including = true; include ('helper.php'); $q=$_GET["q"]; $day=$_GET["day"]; $array = array(); switch ($q) { case "Rice with chicken" : $array = getRiceWithChickenArray(); shuffle($array); break; case "Rice with ghost" : $array = getRiceWithGhostArray (); shuffle($array); break; case "Roti with chicken" : $array = getRotiWithChickenArray (); shuffle($array); break; case "Roti with ghost" : $array = getRotiWithGhostArray (); shuffle($array); break; case "Other" : $array = getOtherArray (); shuffle($array); break; case "Weekend" : $array = getWeekendArray (); shuffle($array); break; } $weekday = str_replace ( "Table", "", $day ); $Weekday = ucfirst(str_replace ( "Table", "", $day )); print ("<table border=1 width=\"600\">"); print ("<tr onmouseover=\"style.background='#C0C0C0'\" onmouseout=\"style.background='white'\"> "); print ("<th align=\"left\" width=\"20%\">".$Weekday.": </th>"); print ("<th align=\"left\" width=\"20%\">". ($q) ." </th>"); print ("<th align=\"left\" width=\"20%\">"); ${$weekday.'sdish'} = array_pop ($array); print (${$weekday.'sdish'} ['name']); print (" "); print ("</th>"); print ("<th align=\"left\" width=\"20%\">". ${$weekday.'sdish'}['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']); print (" </th>"); if (${$weekday.'sdish'} != null) { print ("<th align=\"left\" width=\"20%\"><input type=\"button\" value=\"Try again\" onclick=\"getNewReceipe('" . ($_GET ["q"]). "','".($_GET ["day"])."')\"> </th>"); } if (${$weekday.'sdish'} == null) { print ("<th align=\"left\" width=\"20%\"> </th>"); } print ("</tr>"); print ("</table>"); print ("<input type=\"hidden\" value=\"". (${$weekday.'sdish'}['name'])."\" name=\"sunday\">"); print ("<input type=\"hidden\" value=\"".$q."\" name=\"sundayCategori\">"); ?>