$result = mysql_query("SELECT * FROM pisces_openflashx WHERE id=1");
while($row = mysql_fetch_array($result))
{
$inch = $row['inch'];
$color = $row['color'];
$Jan = $row['Jan'];
$Feb = $row['Feb'];
$Mar = $row['Mar'];
$Apr = $row['Apr'];
$May = $row['May'];
$Jun = $row['Jun'];
$Jul = $row['Jul'];
$Aug = $row['Aug'];
$Sep = $row['Sep'];
$Oct = $row['Oct'];
$Nov = $row['Nov'];
$Dec = $row['Dec'];
}$data = array();$data[] = $Jan;
$data[] = $Feb;
$data[] = $Mar;
$data[] = $Apr;
$data[] = $May;
$data[] = $Jun;
$data[] = $Jul;
$data[] = $Aug;
$data[] = $Sep;
$data[] = $Oct;
$data[] = $Nov;
$data[] = $Dec;printf ($data);
exit; 代码如上。数据库连接正常,$Jan取值也正常,就是赋值到$data[]为空,不知道是什么原因,哪位高手知道的就帮回答一下!
1. array_push($data,$jan); // 插入,下标依次+1,通过下标访问
2. $data["jan"] = $jan; // 通过key插入, 通过key访问, 重名key之间覆盖
$data = array();
while($row = mysql_fetch_array($result))
{
$inch = $row['inch'];
$color = $row['color'];
$Jan = $row['Jan'];
$Feb = $row['Feb'];
$Mar = $row['Mar'];
$Apr = $row['Apr'];
$May = $row['May'];
$Jun = $row['Jun'];
$Jul = $row['Jul'];
$Aug = $row['Aug'];
$Sep = $row['Sep'];
$Oct = $row['Oct'];
$Nov = $row['Nov'];
$Dec = $row['Dec'];
$data[] = (int)$Jan;
$data[] = (int)$Feb;
$data[] = (int)$Mar;
$data[] = (int)$Apr;
$data[] = (int)$May;
$data[] = (int)$Jun;
$data[] = (int)$Jul;
$data[] = (int)$Aug;
$data[] = (int)$Sep;
$data[] = (int)$Oct;
$data[] = (int)$Nov;
$data[] =(int)$Dec;
}
换一下试试