0

我想使用一个 MySQL 查询创建一个包含 2 个动态列的表。我能够制作第一行列,但第二行只是空白。有任何想法吗?这是我当前的代码:

<?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> 
4

2 回答 2

2
<?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());
while($row_dates = mysql_fetch_assoc($result)) {
    $record[] = $row_dates;
}
?>

<html>
<head>
</head>
<body>
<table width="200" border="1">
  <tr>
    <td>NAME</td>
<?php foreach($record as $rec ) { ?>
    <td><?php echo $rec['date'] ?></td>
<?php } ?>
 </tr>
 <tr>//This is the second row set of dynamic columns
   <?php foreach($record as $rec ) { ?>
    <td><?php echo $rec['date'] ?></td>
   <?php } ?>
 </tr>
</table>
</body>
</html>
于 2013-01-18T10:20:35.973 回答
-1

在第二行之前重置获取循环

mysql_data_seek($result,0);
于 2013-01-18T10:22:24.553 回答