我有一个数据库,我手动添加数据。一些字段是:动态列表 - 自动添加数字
ID AA Name Percentage(will be changing once a week)
1 2. Me 10%
2 1. You 40%
当我用我的动态列表调用数据库时,我得到按Perentage排序的所有名称。机管局专栏中,我需要它才能得到这样的结果:
1. You 40%
2. Me 10%
可以很容易地手动AA柱玩(因为我的条目不超过10-15以上),并用百分比匹配,所以我得到了正确显示我需要的。
但是,如果我的条目变成例如30,那么将非常难以将AA列的所有时间都改变为与百分比匹配。
那么,有没有修改,我可以做我的dynamic_list.php,所以我得到了 1. 2. automaticaly产生的?这里是我的dynamic_list.php:
$sql = mysql_query("SELECT * FROM clients WHERE Category='Deksioseis' ORDER BY percentage DESC");
$productCount = mysql_num_rows($sql);
// count the output amount
if ($productCount > 0) {
$i=0;
$dynamicListDeks = '<table id="pl_list" class="list">';
while($row = mysql_fetch_array($sql)){
$id = $row["ID"];
$aa = $row["AA"];
$client_name = $row["Client_Name"];
$short_name = $row["Short_Name"];
$details = $row["Details"];
$percent = $row["Percentage"];
$dynamicListDeks .= ($i==0) ? '<tr>':'';
$dynamicListDeks .= '<td class="lst_aa">
' . $aa . '
</td>
<td class="lst_l">
<img src="../rooms/' . $short_name . '.png" alt="' . $client_name . '" />
</td>
<td class="lst_nam">
<a id="' . $short_name . '" name="' . $short_name . '" class="room">' . $client_name . '</a>
</td>
<td class="lst_det">
' . $details . '
</td>
<td class="lst_per">
' . $percent . '%
<br />
</td>';
$dynamicListDeks .= ($i==1) ? '</tr>':'';
$i++;
($i==2) ? $i=0:'';
}
$dynamicListDeks .='</table>';
} else {
$dynamicListDeks = "";
}
mysql_close();
谢谢您。这是工作。 – Pavlos1316