Page is a not externally linkable
LinusIT - 1:05 pm on Mar 22, 2011 (gmt 0)
I've developed a simple page to retrieve all results from a specific table in a database, this works fine. The results are formatted in just one column at the minute but I would like to split this into two columns.
I have searched and read about arrays but I can't get it to work so I'm hoping someone can help me out.
I've also implemented seperate row colours to make things clearer, I would like to keep this if at all possible.
<?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>
I've pasted the entire page as there isn't much there anyway.
Thanks in advance