Querying & Displaying a pricing table

Querying & Displaying a pricing table

am 25.12.2007 02:35:37 von Ron Piggott

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

. 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.

Would someone help me develop the syntax for this? This is the first
time I have tried to do something like this and I am not sure how to
start.

If you feel I need to re-design my table to make it simpler I don't
think I mind, although I would prefer it stays like it is now. I am
back in the learning curve with this syntax.

Thanks,

Ron

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Querying & Displaying a pricing table

am 03.01.2008 05:37:03 von dmagick

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

. 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.


$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 '';
}
?>
', $row['term'], $units, '


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