Witam!
Mam na stronie formularz(post), który przekazuje mi wszystko co powinien, za wyjątkiem danych z jednej tabeli - błędy takie jak poniżej wyświetlają się dla każdej z kolumn. Tak jakby pola nie istniały albo skrypt nie miał do nich dostępu?
Notice: Undefined index: breakfastf in //reservation_group_admin.php
Warning: Invalid argument supplied for foreach() in //reservation_group_admin.php
Nie rozumiem dlaczego tak się dzieje. Z tej tabeli korzysta też skrypt jQuery i działa to jak powinno - wczytuje dane,liczy i umieszcza wyniki w ostatniej kolumnie.
tabela jest ładowana w miejscu komentarzahtml <!--Wyżywienie-->
if(isset($_POST['postsave']))
{
$fb = array(); //śniadanie cała porcja
$hb = array(); //śniadanie pół porcji
$fl = array(); //obiad cała porcja
$hl = array(); //obiad pół porcji
$fd = array(); //kolacja cała porcja
$hd = array(); //kolacja pół porcji
$fld = array(); //obiadokolacja pełna porcja
$hld = array(); //obiadokolacja pół porcji
$f = array(); //łącznie pełnych porcji
$h = array(); //łącznie połówek porcji
$price_f = array(); //cena wyżywienia za dzień
$dates = array(); //dni
foreach($_POST['breakfastf'] as $value){ //śniadanie cała porcja
array_push($fb,$value);
}
foreach($_POST['breakfasth'] as $value){ //śniadanie pół porcji
array_push($hb,$value);
}
foreach($_POST['lunchf'] as $value){ //obiad cała porcja
array_push($fl,$value);
}
foreach($_POST['lunchh'] as $value){ //obiad pół porcji
array_push($hl,$value);
}
foreach($_POST['dinnerf'] as $value){ //kolacja cała porcja
array_push($fd,$value);
}
foreach($_POST['dinnerh'] as $value){ //kolacja pół porcji
array_push($hd,$value);
}
foreach($_POST['ldinnerf'] as $value){ //obiadokolacja cała porcja
array_push($fld,$value);
}
foreach($_POST['ldinnerh'] as $value){ //obiadokolacja pół porcji
array_push($hld,$value);
}
foreach($_POST['fmeals_total'] as $value){ //łącznie pełnych porcji
array_push($f,$value);
}
foreach($_POST['hmeals_total'] as $value){ //łącznie połówek porcji
array_push($h,$value);
}
foreach($_POST['meals_price'] as $value){ //cena wyżywienia za dzień
array_push($price_f,$value);
}
}
<form method="post">
<p>
<div id="mres-form40" class="nano" style="position: relative;top: -1030px;left: 963px;width: 855px; height:800px;"><div class="nano-content">
<div id="mres-form34" style="position:relative;"><!--Wyżywienie--></div>
<div id="mres-form23" style="left: 225px !important; top: 155px !important;"><input class="btn btn-primary" type="submit" value="ZAPISZ REZERWACJĘ" name="postsave" style="background-color: #00adee; font-family: Antonio-Regular; font-size: 23px; width: 250px; height: 34px;"></div>
</div></div>
</p></form>
skrypt jQuery wczytujący tabelę na stronę
jQuery.post("//food.php",
{
owner: jQuery('#owner_id').val(),
data1: jQuery('#date').val(),
data2: jQuery('#date1').val()
},
function(data) {
console.log("***");
jQuery('#mres-form34').html(data);
});
skrypt food.php generujący tabelę
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
ini_set('display_errors', 0);
$owner_id = $_POST['owner'];
function get_options_mld($select, $owner_id){
include ('//db_joomla.php');
$price = "Obiadokolacja";
$types_mld = array();
$index = 0;
$types_mld[0]= 0;
$index = 1;
$query_disp = "SELECT * FROM jos_program_prices WHERE owner_id = '$owner_id ' AND pricefor= '$price'";
$resultSet = mysql_query($query_disp, $con);
while($row = mysql_fetch_array($resultSet)) {
$type =$row['type'];
$pricefor =$row['pricefor'];
$price_mld=$row['price'];
$types_mld[$type." : ".$price_mld] = $type." : ".$price_mld;
$index++;
}
$options =' ';
while(list($k, $v)=each($types_mld)){
if($select==$k){
$options.='<option value=" '.$k.' "selected> ' .$v. ' </option>';
}
else{
$options.='<option value=" '.$k.' "> ' .$v. ' </option>';
}
}
return $options;
}
function get_options_mb($select, $owner_id){
include ('//db_joomla.php');
$price = "Śniadanie";
$types_mb = array();
$index = 0;
$types_mb[0]= 0;
$index = 1;
$query_disp = "SELECT * FROM jos_program_prices WHERE owner_id = '$owner_id ' AND pricefor= '$price'";
$resultSet = mysql_query($query_disp, $con);
while($row = mysql_fetch_array($resultSet)) {
$type =$row['type'];
$pricefor =$row['pricefor'];
$price_mb=$row['price'];
$types_mb[$type." : ".$price_mb] = $type." : ".$price_mb;
$index++;
}
$options =' ';
while(list($k, $v)=each($types_mb)){
if($select==$k){
$options.='<option value=" '.$k.' "selected> ' .$v. ' </option>';
}
else{
$options.='<option value=" '.$k.' "> ' .$v. ' </option>';
}
}
return $options;
}
function get_options_ml($select, $owner_id){
include ('//db_joomla.php');
$price = "Obiad";
$types_ml = array();
$index = 0;
$types_ml[0]= 0;
$index = 1;
$query_disp = "SELECT * FROM jos_program_prices WHERE owner_id = '$owner_id ' AND pricefor= '$price'";
$resultSet = mysql_query($query_disp, $con);
while($row = mysql_fetch_array($resultSet)) {
$type =$row['type'];
$pricefor =$row['pricefor'];
$price_ml=$row['price'];
$types_ml[$type." : ".$price_ml] = $type." : ".$price_ml;
$index++;
}
$options =' ';
while(list($k, $v)=each($types_ml)){
if($select==$k){
$options.='<option value=" '.$k.' "selected> ' .$v. ' </option>';
}
else{
$options.='<option value=" '.$k.' "> ' .$v. ' </option>';
}
}
return $options;
}
function get_options_md($select, $owner_id){
include ('//db_joomla.php');
$price = "Kolacja";
$types_md = array();
$index = 0;
$types_md[0]= 0;
$index = 1;
$query_disp = "SELECT * FROM jos_program_prices WHERE owner_id = '$owner_id ' AND pricefor= '$price'";
$resultSet = mysql_query($query_disp, $con);
while($row = mysql_fetch_array($resultSet)) {
$type =$row['type'];
$pricefor =$row['pricefor'];
$price_md=$row['price'];
$types_md[$type." : ".$price_md] = $type." : ".$price_md;
$index++;
}
$options =' ';
while(list($k, $v)=each($types_md)){
if($select==$k){
$options.='<option value=" '.$k.' "selected> ' .$v. ' </option>';
}
else{
$options.='<option value=" '.$k.' "> ' .$v. ' </option>';
}
}
return $options;
}
$date1 = $_POST['data1'];
$date2 = $_POST['data2'];
$range = strtotime($date2)-strtotime($date1);
$range = floor($range/(60*60*24));
$tmp0 = array();
$tmp4 = "";
$index = 0;
$result = '<div id="resg_s2"><a href="#"><span class="icon-question-sign" style="color: white;font-size: 1.4em;position: relative;left: 510px;top: 13px;"></span></a></div></br></br> <div id="mres-form41" style="position:relative; width:240px;"><label for="types_mb">*CENA ŚNIADANIA</br>(zł/porcja):</label> <select name = "types_mb" id ="types_mb" style="width: 210px;" required>'.get_options_mb($selected, $owner_id).'</select></div><div id="mres-form42" style="position:relative; width: 220px;left: 219px;top: -78px;"><label for="types_ml">*CENA OBIADU</br>(zł/porcja):</label><select name = "types_ml" id ="types_ml" style="width: 210px;" required>'.get_options_ml($selected, $owner_id).'</select></div><div id="mres-form43" style="position:relative; width: 240px;left: 424px;top: -156px;"><label for="types_md">*CENA KOLACJI </br>(zł/porcja):</label> <select name = "types_md" id ="types_md" style="width: 210px;" required>'.get_options_md($selected, $owner_id).'</select></div><div id="mres-form44" style="position:relative; width: 240px;left: 635px;top: -234px;"><label for="types_mld">*CENA OBIADOKOLACJI</br>(zł/porcja):</label> <select name = "types_mld" id ="types_mld" style="width: 210px;" required>'.get_options_mld($selected, $owner_id).'</select></div></br><table name="table" id="table_food" border="1" style="color:1c4e93; position:relative; top:-240px; border-bottom:none; background:Transparent; border-color: #d4d2d2; color: #08C;"><thead><th class = "th" style="background-color: #57c7da;border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25); width:70px;"><input type="hidden" name="lp" value="lp" />DZIEŃ</th><th class = "th" style="width: 70px; background-color: #57c7da;border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name="type" value="type" />ŚNIADANIE</th><th class = "th" style="width: 45px; background-color: #57c7da;border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name="vac" value="vac" />ŚNIADANIE</br>PÓŁ PORCJI</th><th class = "th" style="width:60px; background-color: #57c7da;border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name=" " value=" " />OBIAD</th><th class = "th" style="width: 60px; background-color: #57c7da;border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name="blc" value="blc" />OBIAD</br>PÓŁ PORCJI</th><th class ="th" style="width: 40px; background-color: #57c7da; border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name="room_nr" value="" />KOLACJA</th><th class = "th" style="width: 40px; background-color: #57c7da;border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name="floor" value="" />KOLACJA</br> PÓŁ PORCJI</th><th class = "th" style="width: 55px; background-color: #57c7da; border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name="dost" value="" />OBIADO-</br>KOLACJA</th><th class = "th" style="width: 55px; background-color: #57c7da; border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name="dost" value="" />OBIADO-</br>KOLACJA</br>PÓŁ PORCJI</th><th class = "th" style="width: 55px; background-color: #57c7da; border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name="dost" value="" />ŁACZNIE</br>PEŁNYCH</br>POSIŁKÓW</th><th class = "th" style="width: 55px; background-color: #57c7da; border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name="dost" value="" />ŁACZNIE</br>PÓŁ PORCJI</br>POSIŁKÓW</th><th class = "th" style="width: 55px; background-color: #57c7da; border-color: #d4d2d2; color: #fff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);"><input type="hidden" name="dost" value="" />ŁĄCZNA</br>CENA</th></thead><tbody>';
for($i=0; $i<$range+1; $i++){
$result.='<tr><td class="container_rom" width = "40px;"><center><b>'.date("Y-m-d", strtotime($date1."+".$i."day")).'</b></td><td class="container_rom" ><div style="text-align: center; width:70px;"><input type="number" name="breakfastf[]" value="0" style="width: 60px;" min="0"/></div></td><td class="container_rom"><div class="td_div" style="text-align: center; width:80px;"><input type="number" name="breakfasth[]" value="0" style="width: 60px;" min="0"/></div></td><td class="container_rom"><div style="text-align: center; width:60px;"><input type="number" name="lunchf[]" value="0" style="width: 55px;" min="0"/></div></td><td class="container_rom"><div style="text-align: center; width:70px;"><input type="number" name="lunchh[]" value="0" style="width: 55px;" min="0"/></div></td><td class="container_rom"><div style="text-align: center; width:60px;"><input type="number" name="dinnerf[]" value="0" style="width: 50px;" min="0"/></div></td><td class="container_rom"><div style="text-align: center; width:75px;"><input type="number" name="dinnerh[]" value="0" style="width: 60px;" min="0"/></div></td><td class="container_rom"><div style="text-align: center; width:70px;"><input type="number" name="ldinnerf[]" value="0" min="0" style="width: 60px;"></div></td><td class="container_rom"><div style="text-align: center; width:70px;"><input type="number" name="ldinnerh[]" value="0" style="width: 60px;" min="0"/></div></td><td class="container_rom"><div style="text-align: center; width:70px;"><input type="number" name="fmeals_total[]" id="meals_tf'.$i.'" value="0" style="width: 55px;" readonly="readonly"/></div></td><td class="container_rom"><div style="text-align: center; width:70px;"><input type="number" name="hmeals_total[]" id="meals_th'.$i.'" value="0" style="width: 55px;" readonly="readonly"/></div></td><td class="container_rom"><div style="text-align: center; width:70px;"><input style="width: 60px;" type="number" name="meals_price[]" id="meals_p'.$i.'" value="0" readonly="readonly"/></div></td></tr>';
}
$result.='</tbody></table>';
echo $result;
?>