하나의 MySQL 쿼리를 사용하여 2 개의 동적 열이있는 테이블을 만들고 싶습니다. 첫 번째 행을 만들었지 만 두 번째 행은 비어 있습니다. 어떤 아이디어? 두 번째 루프는 아무것도 포함하지 않도록하면서 그렇게 결과 세트 전체에 걸쳐 반복 한 루프 동안PHP가있는 동적 테이블 열
<?php
$query_dates ="SELECT uploadedby, count(item) as item, date_format(uploaddate, '%m-%d-%y') as date FROM `imsexport` WHERE uploadedby='Gerry Dellosa' and uploaddate between '2012-12-25' and '2013-01-15' GROUP BY date ORDER BY uploaddate ASC";
$result = mysql_query($query_dates,$prepress) or die(mysql_error());
$row_dates = mysql_fetch_assoc($result);
?>
<html>
<head>
</head>
<body>
<table width="200" border="1">
<tr>
<td>NAME</td>
<?php do{?>
<td><?php echo $row_dates['date']?></td>
<?php } while ($row_dates = mysql_fetch_assoc($result)); ?>
</tr>
<tr>//This is the second row set of dynamic columns
<?php do{?>
<td><?php echo $row_dates['date']?></td>
<?php } while ($row_dates = mysql_fetch_assoc($result)); ?>
</tr>
</table>
</body>
</html>
전에 루프를 가져 오기 : 여기에 내 현재 코드입니다 . – shannonman
2 개의 동일한 열을 원하십니까? 아니면 데이터를 2 열로 표시하고 싶습니까? –
@YourCommonSense : 미안하지만 오타였습니다. 두 번째 열 집합은 실제로 $ row_dates [ 'item']에 대한 것입니다. – rain