foreach loop with $value didnot work together with sqlselect where $value
foreach loop with $value didnot work together with sqlselect where $value
I made foreach loop for index array to print a table. $value is also used for echo some values from next associative array(s)...
I would use $value for MySQL select table where var $value is used for WHERE parameter.
But nothing happend. Maybe could someone find the bug. Im helpless now, Im working on it last 14 hours and my brain is usless now. Can somebody help please?
Its all in this part of code:
foreach ($seraz_soupis_pot as $key => $value) {
$sqlshowpotraviny = "SELECT nazev, jednotka, jednotkajeg FROM ft_potraviny WHERE nazev = $value";
$resultshowpotraviny = mysqli_query($link, $sqlshowpotraviny);
$rowshowpotraviny = mysqli_fetch_assoc($resultshowpotraviny);
if ($rowshowpotraviny['jednotka'] == "g") {
$nasobek = "";
$jednotka = "";
} else {
$nasobek = $rowshowpotraviny['jednotkajeg'];
$jednotka = $rowshowpotraviny['jednotka'];
}
$sumpotr = $ass_pole_po[$value] + $ass_pole_ut[$value] + $ass_pole_st[$value] + $ass_pole_ct[$value] + $ass_pole_pa[$value];
echo '<tr><td>' . $value . '</td><td>' . $ass_pole_po[$value];
/* if ($nasobek != "") {*/
echo ($ass_pole_po[$value] / $nasobek);
echo $jednotka;
/* }*/
echo '</td><td>' . $ass_pole_ut[$value] . '</td><td>' . $ass_pole_st[$value] . '</td><td>' . $ass_pole_ct[$value] . '</td><td>' . $ass_pole_pa[$value] . '</td><td>' . $sumpotr . '</td></tr>';
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.