问题描述
我有这个脚本
$query = "SELECT id,last_name,first_name FROM users WHERE tmima_id='6'";
$result = @mysql_query($query);
while($row = mysql_fetch_array($result))
{
$i = 3;
$emp_id = $row['id'];
$cell = 'A'.$i;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($cell, $row['last_name']. $row['first_name']);
$i++;
}
但是在.xls文件中,它仅输出一个用户.为什么id不能打印所有用户? W
But in the .xls file it prints only one user. Why id doesnt print all of the users ? W
谢谢.
我用$ sheet修改了你所说的
I make the change you said with $sheet
$query = "SELECT id,last_name,first_name FROM users WHERE tmima_id='6'";
$result = @mysql_query($query);
while($row = mysql_fetch_array($result))
{
$i = 3;
$emp_id = $row['id'];
$cell = 'A'.$i;
$sheet->setCellValue($cell, $row['last_name']. $row['first_name']);
$i++;
}
但是它仍然只打印出一条记录.是的,当我在phpmyadmin中运行查询时,它返回多个记录.
But it still prints out only one record. And yes when i run the query in phpmyadmin it returns more than one record.
如何从mySql表中打印数据.出了什么问题?
How can i print out data from mySql table.. What is going wrong ?
推荐答案
我很确定这是因为您使用的是唯一标识符(WHERE tmima_id ='6').它只是找到那个唯一标识符的结果并显示出来.希望这会有所帮助.
I am pretty sure it is because you are using a unique identifier (WHERE tmima_id='6'). It is only finding the results for that one unique identifier and displaying that. Hope this helps.
这篇关于表中有关PHPExcel库和mySQL数据的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!