You are here: Re: A query from $_POST using foreach « All PHP « IT news, forums, messages
Re: A query from $_POST using foreach

Posted by Steve on 11/09/06 17:08

"kenoli" <kenoli@igc.org> wrote in message
news:1163089921.908504.296570@b28g2000cwb.googlegroups.com...
| Thanks. Please take no offense about the bickering remark; It was more
| of an appreciation of the energy that gets put into these posts.
|
| So, suppose I wanted to derive something like:
|
| WHERE $key1=$value1 AND $key2=$value2 . . .
|
| from my $_POST?

wow...i really should read before posting. ;^)

here's the straight-forward approach:

$criteria = 'WHERE 1 = 1';
foreach ($_POST as $label => $value)
{
$criteria .= ' AND ' . $label . " = '" . $value . "'"
}
echo '<pre>' . $criteria . '</pre>';

now, you could do it by trimming the last 'and' off but, this way you don't
need be concerned with it.

 

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

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