Re: [PHPLIB] ooh_forms multiple option From: Davor Cengija (davor <email protected>)
Date: 01/31/00

On Sun, 30 Jan 2000, Trevor Cordes wrote:

[...]
>I want to put a few dozen checkboxes (distinct entities, NOT radio
>buttons) on a form. I want to use a loop to generate them and a loop
>to interpret the results after the POST.
>
>Am I correct in assuming that this is what the multiple feature is for?
[...]
>
>Can someone give me a code example or let me know that this isn't
>possible?

        Here it comes, hope you'll understand:

[...]

$f->add_element(array(
                "type" => "checkbox",
                "multiple" => "1",
                "extrahtml" => "checked",
                "name" => "mailto"));

if($cmd == 'send') {

        [...]

        $bcc = "$mailto[0]";
         
        /* ---------- This is it --------- */
        for($i=1; $i<count($mailto); $i++) {
                $bcc .= ",$mailto[$i]";
        }
        
        [...]

        mail($to, $subj, $msg, $extrahdr);
}

        And in the html, to generate the checkboxes from the content
        fetched from the database:

$mailto = array();
while($q->next_record()) {
        printf("<tr><td align=right>%s</td><td>", $q->f("name"));
        $mailto[] = $q->f("username");
        $f->show_element("mailto", $q->f("username"));
        printf("</td></tr>\n");
}

        username is the email address of each user/subscriber.
        $f->show_element() generates mailto[] checkboxes. The loop in
        the first part of this msg takes those emails and creates Bcc:
        field for the email announcing system (one way mailing list).

-- 
      v
Davor Cengija
davor <email protected>
===================================
"Please allow 30 days for delivery"

- PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>. To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in the body, not the subject, of your message.