这是我的代码:
<?PHP
$r = mysql_query("SELECT * FROM `statistics` order by DAY desc");
while($rowi = mysql_fetch_assoc($r))
{
$v = addslashes($rowi['visits']);
$visits = array($v);
}
echo "<h1>$visits</h1>";
?>
我想创建如下所示的echo结果:
"January", "February", "March", "April", "May", "June", "Jul"
但是我的代码无效。你能帮助我吗,我不明白我的错误在哪里。
提前致谢!
答案 0 :(得分:2)
尝试此代码,你必须将项目附加到数组insde你的while循环
$r = mysql_query("SELECT * FROM `statistics` order by DAY desc");
$visits = array();
while($rowi = mysql_fetch_assoc($r))
{
$v = addslashes($rowi['visits']);
$visits[] = $v;
}
echo implode(",",$visits);