我有一个来自 ID 号的 MySQL 查询的数组,我试图将它添加到已经创建的会话数组中。出于某种原因,我的代码是在已经存在的会话数组中添加一个数组,而不仅仅是将 ID 号添加到会话中。是什么导致这种情况发生?
这是我的PHP...
//Find members of this group and create an array to add to cart
$deletedgroupmembersquery = "SELECT * FROM groupmember WHERE group_id='$groupid'";
$deletedgroupmembers = mysql_query($deletedgroupmembersquery) or die('SQL Error :: '.mysql_error());
if (mysql_num_rows($deletedgroupmembers) > 0) {
$groupmembers = mysql_num_rows($deletedgroupmembers);
$cart = array();
while(($deletedmembersrow = mysql_fetch_assoc($deletedgroupmembers))) {
$cart[] = $deletedmembersrow['contact_id'];
}
//Add the array to the cart session
if (isset($cart)) {
$_SESSION['cart'] = array();
array_push($_SESSION[cart],$cart);
} else {
}
这是上面代码正在创建的会话..
Array ( [cart] => Array ( [0] => Array ( [0] => 1362 [1] => 1371 [2] => 2241 ) )
谢谢你的帮助。