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.
[Back to original message]
|