我有下面的查询,我试图循环结果,但echo只返回数组的第二个字母而不是整个第二个数组。
$tsql = "SELECT UserId, Email FROM Membership";
$stmt = sqlsrv_query($conn, $tsql);
$row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC);
while ($row) {
$body .= $row[0];
foreach($row as $email)
{
echo $email[1]. "<BR> ";
}
}
;
答案 0 :(得分:1)
你的代码有太多问题。你应该使用像
这样的东西$tsql = "SELECT UserId, Email FROM Membership";
$stmt = sqlsrv_query($conn, $tsql);
while ($row = sqlsrv_fetch_assoc($stmt, SQLSRV_FETCH_ASSOC) ) {
echo $row [UserId]. "<BR> ";
echo $row [Email ]. "<BR> ";
};