试图只获得唯一的电子邮件,但也显示运输名称。
$sql=mysql_query("SELECT DISTINCT(email) As email FROM tbl_order");
while($row = mysql_fetch_array($sql))
{
echo " ".$row['shipping_name'].",".$row['email']." <br />";
}
但它没有显示运输名称,任何帮助都会很棒,非常感谢。
尝试这个 :
SELECT DISTINCT(email) As email,shipping_name FROM tbl_order" ;
做这个
("SELECT DISTINCT(email) AS email, shipping_name FROM tbl_order")
或者
("SELECT email, shipping_name FROM tbl_order GROUP BY email")
给你确切的代码:
$resultArray = array();
$sql=mysql_query("SELECT DISTINCT(email) as email,shipping_name FROM tbl_order");
$i = 0;
while($row = mysql_fetch_array($sql))
{
//echo " ".$row['shipping_name'].",".$row['email']." <br />";
$resultArray[$i]['shipping_name'] = $row['shipping_name'];
$resultArray[$i]['email'] = $row['email'];
$i++;
}
var_dump($resultArray);
$sql=mysql_query("SELECT DISTINCT(email) As email,shipping_name FROM tbl_order");
while($row = mysql_fetch_array($sql))
{
echo " ".$row['shipping_name'].",".$row['email']." <br />";
}