Re: PHP/MySQL and Checkboxes
- From: Martin Jay <martin@xxxxxxxxxxxxxxxx>
- Date: Fri, 26 May 2006 22:24:11 +0100
In message <1148669676.491946.94730@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
sloane.irwin@xxxxxxxxx writes
I'm sorry but this is all brand new to me. My boss wanted me to use
INSERT INTO SET using the VALUES keyword, and everything works fine
except for the checkboxes. Can checkboxes not be used unless with an
array?
Yes they can. I think the problem with your code is that if the drive1
box isn't ticked on the web page, $_REQUEST['drive1'] won't exist. So,
this portion of the code I posted:
isset($_REQUEST['drive1'])) ? $_REQUEST['drive1'] : "";
returns either the value of $_REQUEST['drive1'] if it exists, or ""
(empty) if it doesn't.
Also, I don't just want certain checkboxes checked in the view/edit
page, I want the ones that correspond to the row in the db checked
because each entry will be different.
An example of how to do this would be to change:
<input type="checkbox" name="drive1" value="yes">
to this:
<input type="checkbox" name="drive1" value="yes" <?php
isset($_REQUEST['drive1'] echo "checked"; ?>>
So that if $_REQUEST['drive1'] exists the word "checked" becomes part of
the <INPUT> element and the box is checked.
--
Martin Jay
Phone/SMS: +44 7740 191877
Fax: +44 870 915 2124
.
- References:
- PHP/MySQL and Checkboxes
- From: sloane . irwin
- Re: PHP/MySQL and Checkboxes
- From: Martin Jay
- Re: PHP/MySQL and Checkboxes
- From: sloane . irwin
- PHP/MySQL and Checkboxes
- Prev by Date: Re: Clearing Variable and Functions
- Next by Date: Re: Clearing Variable and Functions
- Previous by thread: Re: PHP/MySQL and Checkboxes
- Next by thread: PHP give me empty page
- Index(es):
Relevant Pages
|