而不是使用字符串分隔符,在第 7 行还有其他方法吗?
$q = "SELECT * FROM user";
$res = mysqli_query($conn, $q) or die(mysql_error());
$userList = "";
while($user = mysqli_fetch_array($res)) {
$userList .= $user['userList'].";;";
}
echo $userList;
$userList .= $user['userList'].";;";
表示名为 userList 的变量将附加查询结果。在每个结果后附加“;;” 因为时期。
如果您不想附加 ;; 请执行下列操作:
$q = "SELECT * FROM user";
$res = mysqli_query($conn, $q) or die(mysql_error());
$userList = "";
while($user = mysqli_fetch_array($res)) {
$userList .= $user['userList'];
}
echo $userList;