0
我想使數據在2列,而不是一個在這裏展示的代碼是我目前使用的1個欄,顯示的數據:如何使MySQL數據顯示在2列中?
<?php
include("config.php");
include("opendb.php");
$get_cats = mysql_query("SELECT * FROM `categories` ORDER BY `displayorder`") or die(mysql_error());
$get_info = mysql_query("SELECT * FROM `systeminfo`") or die(mysql_error());
$info = mysql_fetch_array($get_info);
while($cats = mysql_fetch_array($get_cats)) {
$get_rares = mysql_query("SELECT * FROM `rares` WHERE `catid`='".$cats['id']."'") or die(mysql_error());
echo("<h2>".$cats['name']."</h2><br>
<table width=\"100%\" border=\"0\">
<tr>
<td width=\"20%\" style=\"text-align:center\"><b>Image</b></td>
<td width=\"40%\" style=\"text-align:left\"><b>Item Name</b></td>
<td width=\"10%\" style=\"text-align:center\"><b>Value</b></td>
<td width=\"30%\" style=\"text-align:center\"><b>Last Updated</b></td>
</tr>
");
$color1 = $info[stripe1];
$color2 = $info[stripe2];
$row_count = 0;
while($rare = mysql_fetch_array($get_rares)) {
$row_color = ($row_count % 2) ? $color1 : $color2;
?>
<tr>
<td width="5%" style="text-align:center;background-color:#<?php echo $row_color; ?>"><img alt="" src="<?php echo("".$info[imagepath]."".$rare['image'].""); ?>"></td>
<td width="20%" style="text-align:left;background-color:#<?php echo $row_color; ?>"><?php echo $rare['name']; ?></td>
<td width="20%" style="text-align:center;background-color:#<?php echo $row_color; ?>"><?php echo $rare['value']; ?> Credits</td>
<td width="10%" style="text-align:center;background-color:#<?php echo $row_color; ?>"><?php echo $rare['lastedited']; ?></td>
</tr>
<?php
$row_count++;
}
echo("</table><br>
");
}
?>
目前顯示爲:
1
_________
2
_________
3
_________
4
_________
5
_________
6
_________
我想它顯示是這樣的:
1 | 2
_________ | _________
3 | 4
_________ | _________
5 | 6
_________ | _________
嗨,我收到以下錯誤: 解析錯誤:語法錯誤,意想不到的T_IF,期待「」或‘;’在線40上的/home/.../public_html/values/show_rares.php – Dean
固定的「;」在最後的後失蹤「,非常感謝。 – Dean
沒問題院長,我更新了代碼以反映 – DaOgre