Ron Piggott wrote:
I am trying to query my rate_plan table and then display the results in
a table format. I need help developing then SELECT syntax and how I am
able to echo the results in a <table>. I want to display the results 7
columns, 4 rows. There are 7 tenures:
I have rate plans set up for:
1 week (term =1; unit =1)
2 weeks (term =2; unit =2)
3 weeks (term =3; unit =2)
1 month (term =1; unit =3)
6 weeks (term =6; unit =1)
2 months (term =2; unit =4)
3 months (term =3; unit =4)
I have advertising rate plans ("type" field) 1 to 4 stored in the table
and the available and expires date of each plan.
The field "unit" is meant to express:
1 for Week
2 for Weeks
3 for Month
4 for Months
The table structure for rate_plan is:
reference int(3) auto_increment
name varchar(50)
type int(1)
term int(5)
unit int(1)
rate decimal(4,2)
available date
expires date
The "rate" field is the dollar value for the rate plan.
<table>
<?php
$query = "select * from rates";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
switch ($row['unit']) {
case '1':
$units = ' Week';
break;
case '2':
$units = ' Weeks';
break;
// etc
}
echo '<tr><td>', $row['term'], $units, '</td></tr>';
}
?>
</table>
Should be enough to get you started.
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php