I have created a table (using css) to display 3 different levels of pricing. The price level depends on what time of year it is. The 3 column headings display the data ranges for which the prices apply. There can be more than one date range for a given price level as shown below:
agency car_from car_until rate_table
Avis 2009-08-16 2009-12-15 1
Avis 2009-01-01 2009-06-14 1
Avis 2009-06-15 2009-08-15 2
Avis 2009-12-15 2009-12-31 3
I have the prices displaying properly but am having trouble displaying the date ranges in the column headings. It places the 2nd date range for the 1st column in the 2nd column, which is price level 2. Here is my attempt at code:
the html to display the headingsCode:$sql = "SELECT * FROM dates WHERE `agency` = '".$agency."' AND rate_table > 0 ORDER BY rate_table"; $result1 = mysql_query($sql,$connection) or die("Couldn't execute $sql query."; $i=0; while ($row = mysql_fetch_array($result1)) { $i++; $car_from[$i] = $row['car_from']; $car_until[$i] = $row['car_until']; $daterange[1] = $car_from[1]." - ".$car_until[1]."<br>"; $daterange[2] = $car_from[2]." - ".$car_until[2]."<br>"; $daterange[3] = $car_from[3]." - ".$car_until[3]."<br>"; }
This is what it looks like: http://www.carrentalhawaii.com/html/rates3.phpCode:<div class="tablehead">Effective Dates<br><?php echo $daterange[1]; ?></div> <div class="tablehead">Effective Dates<br><?php echo $daterange[2]; ?></div> <div class="tablehead">Effective Dates<br><?php echo $daterange[3]; ?></div>
How do I tell it to put 2 date ranges in column one instead of moving it to column 2?
I never did quite grasp the use of [$i]. Thanks.



Reply With Quote

Bookmarks