<?php
$kid = $_SESSION["kid"];
$sql = "SELECT Gericht_ID FROM `warenkorb` WHERE Kunde_ID = '$kid'";
$result = mysqli_query($con,$sql);
if(mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
$_SESSION['row_gid'] = $row["Gericht_ID"];
print $_SESSION['row_gid']; // he return me here 2 9 10 11
}
}
print $_SESSION['row_gid']; // but here just only 11
?>
我的问题是如何将SESSION
中的值保存为所有数字2 9 10 11不仅仅是11?
答案 0 :(得分:1)
您可以使用$_SESSION['row_gid'][]
,然后在外部循环打印$_SESSION['row_gid']
。
答案 1 :(得分:0)
从
改变$sql = "SELECT Gericht_ID FROM `warenkorb` WHERE Kunde_ID = '$kid'";
到
$sql = "SELECT group_concat(Gericht_ID separator ',') as Gericht_ID FROM `warenkorb` WHERE Kunde_ID = '$kid'";