php - 在php中如何显示mysql的结果?

标签 php sql mysql

我有一个 mysql 表,其中保存电子邮件地址。结构如下:

id    ||    email

但是,我如何在 php 中实际输出这些以逗号分隔的电子邮件地址?

预先感谢您的帮助!

最佳答案

使用:

<?php
 $query = "SELECT GROUP_CONCAT(t.email) AS emails
             FROM YOUR_TABLE t"

 // Perform Query
 $result = mysql_query($query);

 while ($row = mysql_fetch_assoc($result)) {
    echo $row['emails'];
 }

 // Free the resources associated with the result set
 // This is done automatically at the end of the script
 mysql_free_result($result);
?>

引用资料:

关于php - 在php中如何显示mysql的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3903104/

相关文章:

php - sql 活出另一个表中的项目

MySQL : GROUP_CONCAT the column and its count

php - 将多个选择选项放入 PHP 数组

MYSQL 每日平均值

sql - 满足一定条件的Mysql Order结果

mysql - SQL 查询字段作为列

php - 使用 htaccess 强制下载图像

php - Laravel - Cloud9 Paginator 生成不需要的 https 链接

php - 解析错误,期望 activecollab 模型类中出现 `T_PAAMAYIM_NEKUDOTAYIM' 错误

mysql - 更改字符集后无法添加外键约束