I am using the following code to display a table with alternating colors. I have a field called "order" in the database where I wish to specify which row appears first in my html table.
No matter what I put, it displays the rows in order they appear in the database instead of ordered by the "Order" field.
Any clue what I am doing wrong???
$query = "SELECT * FROM table ORDER BY '$order'";
$result = mysql_query($query) or die ("Query failed");
$numofrows = mysql_num_rows($result);?>
<?PHP echo "<TABLE BORDER=\"0\">\n";
echo "<TR bgcolor= #00033ff><TD>site</TD><TD>description</TD><TD>URL</TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result);
if($i % 2) {
echo "<TR bgcolor='#0033ff'>\n";
} else {
echo "<TR bgcolor='#f1e4ad'>\n";
}
echo "<TD>".$row['field1']."</TD><TD>".$row['field2']."</TD>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";?>