Re: Re[2]: [PHP] checkbox
| From: | Folke Ashberg | Date: | Sat, 25 Nov 2000 21:43:00 +0000 |
| Subject: | Re: Re[2]: [PHP] checkbox | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27185@lists.php.net to get a copy of this message | ||
Hi Richard,
i can't write the if condition for because i don't know what
you expect in the mySQL-field for an checked checkbox and what for an
unchecked.
for example :
<?php if ($row[frontpage]=="Y") print " checked"?>
ok?
regards
Folke
--
Folke Ashberg
Stage Internet Services GmbH
Technical Development
folke@fanstage.de
folke@fanstage.de | Tel: +49 89 454591-77 | Fax: +49 89 454591-71
Kreillerstr. 21 | 81673 Munich | Germany | www.fanstage.de
On Sat, 25 Nov 2000, Richard Kurth wrote:
> Hello Folke,
>
> I understand that I need to wright a if statement I am not sure how
> to wright it or where to put it
>
> FA> you can check checkboxes with an "checked"
>
> FA> <input type="checkbox" name="terms"
> FA> value="<?php echo $row["frontpage"]?>"
> FA> <?php if (your_condition) print " checked"?>
> >>
>
> >
> > I know this should be simple to figure out but I am stuck.
> > I have three check boxes on a form all for different things.
> > When I check them or don't check them they add ether yes or no to
> > the database field corresponding to them. This is what I want them
> > to do. My problem is when I pull the data back in to a form for
> > update or viewing. I can not figure out how to make the check boxes be
> > checked if the value is yes.
> >
> > <?php
> > $query = "SELECT * FROM pcustomers WHERE id = $id";
> > $result=mysql_db_query($dbName,$query);
> > $row = mysql_fetch_array($result);
> > mysql_free_result($result);
> >
> > ?>
> >
> > <input type="checkbox" name="frontpage" value="<?php echo
$row["frontpage"] ?>">
>
> > <input type="checkbox" name="terms" value="<?php echo
$row["terms"] ?>">
>
> > <input type="checkbox" name="wantdatabase" value="<?php
echo $row["wantdatabase"] ?>">
> >
>
>
>
>