Hi! I have built a mySQL query that prints html tables. I need to split the tables into 2 equal parts. This is the code:
<?php
include "../functions/charset.php";
include "../functions/basic.php";
dbconnect("eurocult");
echo "<table border='1'><tr>";
$sql= "SELECT * FROM cities, hotels
WHERE hotels.country_id=1 AND
cities.country_id=1 AND
cities.city_id=hotels.city_id
order by city
";
$result = @mysql_query($sql);
while ($row = @mysql_fetch_array($result)) {
echo "<tr>\n";
if ($prevcity != $row['city']) {
$prevcity = $row['city'];
echo "<td colspan='3' bgcolor='#999999'>".$row['city']."</td>\n";
echo "<tr><td>".$row['name']."</td>\n
<td>".$row['double_euro']."</td>\n
<td>".$row['single_euro']."</td>\n
</tr>\n
<tr>\n
<td colspan=\"3\">".$row['description']."</td>\n
</tr>\n";
}
else {
echo "<td>".$row['name']."</td>\n
<td>".$row['double_euro']."</td>\n
<td>".$row['single_euro']."</td>\n
</tr>\n
<tr>\n
<td colspan=\"3\">".$row['description']."</td>\n
</tr>\n";
}
}
echo ("</tr></table>");
?>
I have one more problem also, the code is printing a city name and the hotels in it. I need to order the cities, but not alphabetically, but by the city_id. I do not want the city_id printed in the result. Is there a way to tell mySQL to interpret the 'order by' statement not alphabetically, but numeric? Thanks! Valeri