我有這個表:顯示SQL表和比較值
+----+---------------------+----------+---------+---------+---------+
| id | date | client1 | client2 | client1 | client1 |
+----+---------------------+----------+---------+---------+---------+
| 1 | 2013-04-17 16:15:46 | 8592 | 9786 | 6471 | 0 |
| 2 | 2013-04-27 16:15:46 | 8617 | 9876 | 7130 | 40243 |
| 3 | 2013-04-28 17:57:30 | 8617 | 9884 | 7211 | 41657 |
| 4 | 2013-04-29 13:28:11 | 8616 | 9886 | 7270 | 42516 |
+----+---------------------+----------+---------+---------+---------+
而且我在PHP顯示它是這樣的:
<table width="800" border="0" cellspacing="3" cellpadding="3" style="margin-left:auto; margin-right:auto">
<tr>
<th scope="col" style="text-align:center; font-weight:bold">Date</th>
<th scope="col" style="text-align:center; font-weight:bold">Client 1</th>
<th scope="col" style="text-align:center; font-weight:bold">Client 2</th>
<th scope="col" style="text-align:center; font-weight:bold">Client 3</th>
<th scope="col" style="text-align:center; font-weight:bold">Client 4</th>
</tr>
<?
$queryuv = mysql_query("SELECT * FROM com_information ORDER BY date ASC");
while ($resultuv=mysql_fetch_assoc($queryuv)) {
$date=$resultuv['date'];
$client1=$resultuv['client1'];
$client2=$resultuv['client2'];
$client3=$resultuv['client3'];
$client4=$resultuv['client4'];
?>
<tr>
<th scope="row" style="text-align:left"><?=$date?></th>
<td style="text-align:center"><?=number_format($client1,0,'.',',');?></td>
<td style="text-align:center"><?=number_format($client2,0,'.',',');?></td>
<td style="text-align:center"><?=number_format($client3,0,'.',',');?></td>
<td style="text-align:center"><?=number_format($client4,0,'.',',');?></td>
</tr>
<? } ?>
</table>
我想什麼做的,是在表是我顯示信息,比較來自同一客戶端的前一個日期的值,並且顯示它的增長或減少的程度。
對的,因爲這'client'柱,再? :) – 2013-04-30 18:49:15
爲什麼「client1」列在您的表中重複3次?這可能是一個錯字嗎? – Revent 2013-04-30 19:02:11