Re: is this code decent?
| From: | Daniel Convissor | Date: | Tue, 21 Nov 2000 22:17:01 +0000 |
| Subject: | Re: is this code decent? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26550@lists.php.net to get a copy of this message | ||
Mark Maggelet wrote:
>
> $prices=array(
> 'Residential' => array(
> 'Qwest 640k/272k' => '19.95',
> 'Qwest 640k/544k' => '39.95',
> 'Qwest 960k/816k' => '59.95',
> 'Qwest 1280k/1088k' => '79.95'
> ),
> 'SOHO' => array(
> // more...
> ),
> 'Business' => array(
> // more...
> )
> );
> $cost=$prices[$servicetype][$servicespeed];
Yep, that works. If you don't have database access, that's the way to go.
But, if you have database access, it'd be better.
$result = mysql_query("select price from prices
where servicetype = '$servicetype'
and servicespeed = '$servicespeed'");
$record = mysql_fetch_array($result, MYSQL_ASSOC);
echo "That service costs " . $record["price"];
--Dan
--
PHP scripts that make your job easier
http://www.analysisandsolutions.com/code/
SQL Solution | Layout Solution | Form Solution
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409