除了使用String分隔符,在第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;

关于php - 字符串分隔符以读取mysql的表数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19164568/

10-10 19:40