Forum Moderators: coopster
<?php
require_once ('includes/config.php');
require_once ('includes/database.php');
$sql="SELECT * FROM pricelist ORDER BY pricelist_grade ASC";
$result = mysql_query($sql) or die(mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<title>Price List</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<link href="css/stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include_once ('includes/menu.php'); ?>
<?php if (mysql_num_rows($result) == 0) {
echo "<h1>No Results Found</h1>";
} else { ?>
<table cellpadding="0" cellspacing="0" id="models">
<tr class="headings">
<th class="model">Grade</th>
<th class="weight">PMT</th>
</tr>
<?php
$color1 = "#D7DFFF";
$color2 = "#F3F3F3";
$row_count = 0;
while($row=mysql_fetch_array($result)) {
$row_color = ($row_count % 2) ? $color1 : $color2;
?>
<tr style="background-color:<?php echo $row_color ?>;">
<td><?=$row['pricelist_grade']?></td>
<td>£<?=$row['pricelist_price']?></td>
</tr>
<?php $row_count++;
}?>
</table>
<?php } ?>
</body>
</html>
<?php
echo"<table cellpadding=\"0\" cellspacing=\"0\" id=\"models\">\n";
echo"<tr><td valign=\"top\" id=\"leftcol\">\n";
$num=mysql_num_rows($result);
$col1=ceil($num/2);
$col2=$num-$col1;
for($j=0;$j<2;$j++)
{
if($j==0)
{
$limit=$col1;
}else{
$limit=$col2;
echo"</td><td valign=\"top\" id=\"rightcol\">\n";
}
echo"<table><tr class=\"headings\"><th class=\"model\">Grade</th><th class=\"weight\">PMT</th></tr>\n";
for($i=0;$i<$limit;$i++)
{
$row=mysql_fetch_assoc($result);
echo"<tr><td>".$row['pricelist_grade']."</td><td>".$row['pricelist_price']."</td></tr>\n";
}
echo"</table>\n";
}
echo"</td></tr></table>\n";
?>