Posted by kenoli on 11/08/06 16:17
I'm trying to create a query from a $_POST variable where the user may
not have included a value in every form field. I need to have the
first" set" variable at the beginning and the rest following it
separated by an AND. Something like:
val1 AND val2 . . . AND val(last)
If I do something like:
foreach ($_POST as $key = $val) {
query .= "$val AND ";
}
or
foreach {$_POST as $key = $val) {
query .= "AND $val ";
}
I end up with an extra AND at the beginning or end.
e.g.:
val1 AND val2 . . . AND val(last) AND
or
AND val1 AND val2 . . . AND val(last)
How can I tell it to treat the first or last occurence without the AND?
--Kenoli
Navigation:
[Reply to this message]
|