我用sql查询创建了这个表,看起来像这样
$result = mysql_query("SELECT * FROM 5050goosedown");
echo "<table border='0' width='975'>
<tr>
<th width='12.5%'>name:</th>
<th width='12.5%'>width:</th>
<th width='12.5%'>height:</th>
<th width='12.5%'>fill:</th>
<th width='12.5%'>our fill:</th>
<th width='12.5%'>old price:</th>
<th width='12.5%'>price:</th>
</tr>";
$i = 1;
while($row = mysql_fetch_array($result)){
echo "<tr bgcolor='#F5F5F5'>";
if($i%2 == 0){
echo "<tr bgcolor='#E5E5E5'>";
}
$i++;
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['width'] . "</td>";
echo "<td>" . $row['height'] . "</td>";
echo "<td>" . $row['normal_fill'] . "</td>";
echo "<td>" . $row['our_fill'] . "</td>";
echo "<td>" . $row['old_price'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo '<td bgcolor=#FFFFFF><form method="post" action=""><input type="hidden" name="goosedown_id" value="'.$row['goosedown_id'].'" /><input type="submit" name="sumbit" value="Delete" /></form></td>';
echo "</tr>";
}
echo "</table>";
?>
我想知道以特定顺序显示表格中的项目的最佳方式是什么,因为目前按字母顺序显示。但是,我希望它以大小的顺序显示,即。,单身,超级单身,女王,国王,超级国王......
我只是不知道如何尝试这个。您认为我可能需要在数据库中输入其他条目吗?
这就是表格的样子..你可以看到有一个部分,人们可以输入自己的值
MySQL的
CREATE TABLE `5050goosedown` (
`goosedown_id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '',
`width` int(8),
`height` int(8),
`normal_fill` int(8),
`our_fill` int(8),
`old_price` DECIMAL(3,2),
`price` DECIMAL(3,2),
PRIMARY KEY (`goosedown_id`)
) TYPE=MyISAM;
答案 0 :(得分:3)
但是我希望它以大小顺序显示,即单个, 超级单身,女王,国王,超级国王...
然后试试这个:
ORDER BY
CASE Size
WHEN 'sigle' THEN 0
WHEN 'super' THEN 1
WHEN 'single' THEN 2
WHEN 'queen' THEN 3
...
END , Name