我想为我的托管公司报价。我提出了一个表格:
CREATE TABLE `planes` (
`id` int(5) unsigned NOT NULL auto_increment,
`DiskSpace` text NOT NULL,
`AnnuallyDataTransfer` text NOT NULL,
`FTPAccounts` text NOT NULL,
`EmailBoxes` text NOT NULL,
`BandwidthAllowance` text NOT NULL,
`FreeDomains` text NOT NULL,
`MySQLDatabases` text NOT NULL,
`price` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
INSERT INTO `planes` VALUES (1, '5GB', 'Unlimited', '25', '1000', 'Unlimited', '1', 'Unlimited', '200 LE');
INSERT INTO `planes` VALUES (2, '10 GB', 'Unlimited', '50', '1000', 'Unlimited', '1', 'Unlimited', '300');
然后我尝试在php
代码中显示这些优惠。这是代码:
<?php
$result = mysql_query("SELECT * FROM planes ORDER BY id DESC LIMIT 0,2") or die(mysql_error());
$Disc = 1;
echo '<table class="ranking">';
echo '<tr><td class="rankhead">#</td><td class="rankhead">Plan1</td><td class="rankhead">Plan2</td><td class="rankhead">plan3</td></tr>';
while($row = mysql_fetch_array( $result )){
$name = $row['AnnuallyDataTransfer'];
$Disc = $row['FTPAccounts'];
$class = $row['EmailBoxes'];
echo '<tr>';
echo '<td class="rankvalues">'.$Disc.'</td>';
echo '<td class="rankvalues">'.$name.'</td>';
echo '<td class="rankvalues">'.$Disc.'</td>';
echo '<td class="rankvalues">'.$class.'</td>';
$Disc++;
echo "</tr>";
}
echo "</table>";
?>
但是我得到了错误设计。我希望将所有商品字段显示在左侧作为列并提供行,每个商品的价值来自左侧字段。
答案 0 :(得分:0)
您使用$Disc
变量进行此类增量,数据库值更正
试试这个
while($row = mysql_fetch_array( $result )){
$AnnuallyDataTransfer = $row['AnnuallyDataTransfer'];
$FTPAccounts = $row['FTPAccounts'];
$EmailBoxes = $row['EmailBoxes'];
echo '<tr>';
echo '<td class="rankvalues">'.$Disc.'</td>';
echo '<td class="rankvalues">'.$AnnuallyDataTransfer.'</td>';
echo '<td class="rankvalues">'.$FTPAccounts.'</td>';
echo '<td class="rankvalues">'.$EmailBoxes.'</td>';
$Disc++;
echo "</tr>";
}
注意: mysql_*
已被弃用[{1}}或mysqli_*