|  | Posted by Chris Hope on 06/11/44 11:16 
Geoff Berrow wrote:
 > I noticed that Message-ID: <neaje.4549$Rr3.236@read1.cgocable.net>
 > from Joe Blow contained the following:
 >
 >>Brilliant, many thanks to both of you. As I suspected, it is a bit
 >>obvious once it is pointed out. I had it your way the other day and
 >>changed it for some reason when struggling with something else.
 >
 > When you are testing every element of an array (in this case the
 > $_POST
 > array)  you may find it more efficient to use a loop.
 >
 > $missing="";
 > foreach($_POST as $key=>$value){
 > if($value==""){
 > $missing="<li>$key</li>";
 > }
 > }
 >
 > if ($missing!=""){
 > echo "Oops, you missed out <ul>$missing</ul>"
 > }
 >
 > Untested.
 
 Or you could do it like this, if you only require some of the fields to
 be completed:
 
 foreach(array('foo', 'bar', 'baz') as $fieldname) {
 if($_POST[$fieldname] == '') {
 ...
 }
 }
 
 --
 Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
  Navigation: [Reply to this message] |