Re: checkboxes
| From: | Jayme Jeffman Filho | Date: | Wed, 27 Sep 2000 15:47:16 +0000 |
| Subject: | Re: checkboxes | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-3115@lists.php.net to get a copy of this message | ||
Sorry I made a mistake, the problem is you are allways setting $checked to a
empty string (''), this line must be before the begining of the while loop:
<?PHP
file://gets all checkboxes
while ($allpreqs = db_fetch_array($preqz)) {
file://gets selected checkboxes
$checked = ''; file://this is the right position !
while ($chkdpreqs = db_fetch_array($prq))
if ($allpreqs['preq_id'] == $chkdpreqs['preq_id']) {
$checked = 'CHECKED';
}
}
echo ("<INPUT TYPE=checkbox NAME=preq[]
VALUE=\"".$allpreqs['preq_id']."\"
".$checked.">".$allpreqs['prereq']."<BR>\n");
}
?>
Jayme.
http://www.conex.com.br/jjeffman
-----Mensagem Original-----
De: Jayme Jeffman Filho <jjeffmanweb@conex.com.br>
Para: <php-db@lists.php.net>; <luis@mecha.barry.edu>
Enviada em: quarta-feira, 27 de setembro de 2000 12:37
Assunto: Re: [PHP-DB] checkboxes
> You need break the process when you'd reached a checked result, so put a
> break statement after the line => $checked = 'CHECKED'; break;
>
> Jayme.
>
> http://www.conex.com.br/jjeffman
>
>
>
> -----Mensagem Original-----
> De: <luis@mecha.barry.edu>
> Para: <php-db@lists.php.net>
> Enviada em: terça-feira, 26 de setembro de 2000 19:18
> Assunto: [PHP-DB] checkboxes
>
>
> > Hello:
> >
> > I have a series of checkboxes on a form that the user can
edit...anyways,
> I want
> > to make the boxes to be checked if the value is in a table...the code
> works
> > below...more or less, because it gets the first one, but not others that
> may be
> > in the db...I know I am close but I can't seem to get it...
> >
> > anyone see my stupid mistake please email me directly as I think my sub
is
> a
> > little flaky...thanks
> >
> > Luis
> >
> > <?
> > file://gets all checkboxes
> > while ($allpreqs = db_fetch_array($preqz)) {
> > file://gets selected checkboxes
> > while ($chkdpreqs = db_fetch_array($prq))
>
> > $checked = '';
> > if ($allpreqs['preq_id'] == $chkdpreqs['preq_id']) {
> > $checked = 'CHECKED';
> > }
> > }
> > echo ("<INPUT TYPE=checkbox NAME=preq[]
> > VALUE=\"".$allpreqs['preq_id']."\"
> ".$checked.">".$allpreqs['prereq']."<BR>\n");
> >
> > }
> > ?>
> >
> > ---------------------------------------------
> > This message was sent using Mecha WebMail.
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-db-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>