我有tho数组,当我删除其他数据时它们都显示结果但我需要在一个函数上显示它们这是我的代码:
<?php
include('connect-db.php');
$result = mysqli_query($conn, "SELECT * FROM my_table ORDER BY Email");
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
$data = array();
while ($row = mysqli_fetch_array($result))
{
$data[] = $row['Email'];
}
sort($data);
echo join($data, ',')
$bax = array();
while ($row = mysqli_fetch_array($result))
{
$bax[] = $row['Name'];
}
echo join($bax, ',')
?>
提前致谢
答案 0 :(得分:2)
您可以在以下while
循环中执行此操作: -
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
include('connect-db.php');
$result = mysqli_query($conn, "SELECT * FROM my_table ORDER BY Email");
if($result === FALSE) {
die(mysqli_error($conn)); // don't mix mysql_* with mysqli_*
}
$data = array();
$bax = array();
while ($row = mysqli_fetch_assoc($result)) // mysqli_fetch_assoc will be better because mysqli_fetch_array is a combination of numeric+associative array while mysqli_fetch_assoc is just giving associative array
{
$data[] = $row['Email'];
$bax[] = $row['Name'];
}
sort($data);
echo join($data, ','); // ; missed
echo join($bax, ','); // ; missed
?>
注意: - 我不能说你的连接代码,所以检查自己。另请阅读评论。