Posted by Koncept on 12/27/06 01:09
In article <1166915475.837969.16300@a3g2000cwd.googlegroups.com>,
kenoli <kenoli@igc.org> wrote:
> foreach ($_POST as $key => $value) {
>
> if(!empty($value)):
>
> switch($key):
> case 'first_name':
>
> $p[] = "first_name = '{$value}'";
> break;
>
> case 'last_name' :
>
> $p[] = "last_name = '{$value}'";
> break;
>
> case 'host' :
>
> $p[] = "host = 'Y'";
> break;
>
> case 'graph_facil' :
>
> $p[] = "graph_facil = 'Y'";
> break;
>
> case 'wcoc_member' :
>
> $p[] = "wcoc_member = 'Y'";
> break;
>
> case 'city_1' :
>
> $c[] = "city_1 = '$value'";
> break;
>
> case 'state_1' :
>
> $c[] = "state_1 = '$value'";
> break;
>
> case 'country_1' :
>
> $c[] = "country_1 = '$value'";
> break;
> endswitch;
> endif;
> }
This code can be simplified to:
<?php
foreach($_POST as $key => $value) {
if(!empty($value)){
switch($key){
case 'first_name':
case 'last_name' :
$p[] = "{$key} = `{$value}`";
break;
case 'host' :
case 'graph_facil' :
case 'wcoc_member' :
$p[] = "{$key} = `Y`";
break;
case 'city_1' :
case 'state_1' :
case 'country_1' :
$c[] = "{$key} = `$value`";
break;
}
}
}
?>
--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
[Back to original message]
|