我有一个 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/