You are here: Re: Constructing a search query « All PHP « IT news, forums, messages
Re: Constructing a search query

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация