字符串分隔符读取表数据mysql

时间:2013-10-03 16:37:21

标签: php mysql mysqli

而不是使用String delimiter,在第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;

1 个答案:

答案 0 :(得分:0)

 $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;