我想将此代码输出到php页面。
SET group_concat_max_len=5000;
SET @sql = NULL;
SELECT GROUP_CONCAT(DISTINCT CONCAT('MAX(IF(date = ''', date, ''', present, NULL)) AS ''',date, ''''))
INTO @sql
FROM tblattendanceregister;
SET @sql = CONCAT('SELECT employee, ', @sql, '
FROM tblattendanceregister
GROUP BY employee');
PREPARE stmt FROM @sql;
EXECUTE stmt;
到目前为止我已尝试过这个:
<table border="0" name="attReportTable" id="attReportTable" class="table table-striped table-header-rotated">
<?php
$dySet=mysql_query("SET group_concat_max_len=5000;
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'MAX(IF(date = ''',
date,
''', present, NULL)) AS ''',date, ''''
)
) INTO @sql
FROM tblattendanceregister;
SET @sql = CONCAT('SELECT employee, ', @sql, ' FROM tblattendanceregister GROUP BY employee');
PREPARE stmt FROM @sql;
EXECUTE stmt;");
while($dy=mysql_fetch_array($dySet)){
?>
<tr>
<td align="center" valign="middle"><div><?php echo $dy["employee"];?></div></td>
<td class="rotate-45"><div><span><?php echo date('d-M',strtotime($dy["date"]));?></span></div></td>
</tr>
<?php
}
?>
</table>
我一直收到这个错误:
警告:mysql_fetch_array()要求参数1为资源,布尔值在第729行的C:\ wamp \ www \ cbmwdb \ systemfiles \ supchain \ PersonnelPerformance.php中给出。
第729行是while循环开始的地方。