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

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]


Удаленная работа для программистов  •  Как заработать на 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

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