我正在尝试从使用创建的多维数组中获取键值。数组快照在代码之后给出。

以下是我的PHP代码-

 $selectTicket =  "select ticketID from ticketusermapping where userID=$userID and distanceofticket <=$miles;";
$rsTicket = mysqli_query($link,$selectTicket);
$numOfTicket = mysqli_num_rows($rsTicket);
if($numOfTicket > 0){
    $allRowData = array();
while($row = mysqli_fetch_assoc($rsTicket)){
    $allRowData[] = $row;
}
 $key = 'array(1)[ticketID]';
    $QueryStr = "SELECT * FROM ticket WHERE ticketID IN (".implode(',', array_keys($key)).")";


阵列快照
php - 无法从mysql多维数组获取键值-LMLPHP

我需要此数组中的tickedID值。像第一个是49。
请帮忙。

最佳答案

像这样更改您的代码

$selectTicket = "select ticketID from ticketusermapping where userID=$userID and distanceofticket <=$miles;";
    $rsTicket = mysqli_query($link, $selectTicket);
    $numOfTicket = mysqli_num_rows($rsTicket);
    if ($numOfTicket > 0) {
        $allRowData = array();
        while ($row = mysqli_fetch_assoc($rsTicket)) {
            $allRowData[] = $row['ticketID'];
        }
        $QueryStr = "SELECT * FROM ticket WHERE ticketID IN (" . implode(',', $allRowData) . ")";

07-23 17:29