Re: PHP/MySQL and Checkboxes



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
.



Relevant Pages

  • Re: Managing 70 checkboxes in financial graphing application
    ... to manage how the checkboxes interact with the data and the graph. ... I have a tab with the data series called "Data". ... This allows the graph to show blanks where data is missing as some series ... My idea is to read the status of all checkboxes into an array. ...
    (microsoft.public.excel.programming)
  • Re: Updating Multiple Rolls Using PHP
    ... I am retrieving records from a table and I ... checkboxes, but my update loop is not working. ... array $_POST. ... Warning: Invalid argument supplied for foreach() in X: ...
    (comp.lang.php)
  • RE: Excel 2003 VBA question
    ... the state of checkboxes until the user clicks "Ok". ... Make a temp array of 6 ... addresses as needed and increment the recipientCount ... If the sendMail function will work with a recipient string like ...
    (microsoft.public.excel.programming)
  • Re: even rows for checkbox forms with no splitting of boxes from values
    ... So I usually roll my own checkboxes. ... In the solution below I wanted to randomize the test script a little ... #this is to create an array with 25-50 strings 2-10 in length ...
    (comp.infosystems.www.authoring.cgi)
  • Re: Grabbing checkbox values
    ... I need to grab only those checkboxes that are checked, so I can then delete those files. ... This array contains data from different ... The 'param' function is part of a perl module that deals with form parsing. ...
    (comp.lang.php)