Re: Problem:



On Oct 28, 4:55 am, rohit reja <rejarohit2...@xxxxxxxxx> wrote:
Hi everyone

I am developing a website..the form in my php page has a lot of
checkboxes..to set differebt options.
Now how do i write mysql query for that form according to checkbox
selected..is there any shorter way.
Plz help

Prepared statements and a foreach over your checkboxes.

foreach ($checkboxes as &$thisCheck)
{
$thisCheck?
$thicCheck = 1:
$thisCheck = 0;
}

$statement = $db -> prepare (UPDATE table SET item1=?, item2=? item3=?
WHERE id=?);
$statement -> execute (array ($checkboxes [0], $checkboxes [1],
$checkboxes [2], $id));
.



Relevant Pages

  • Re: Problem:
    ... checkboxes..to set differebt options. ... Prepared statements and a foreach over your checkboxes. ... way checkboxes work (at least with Apache and PHP), ...
    (comp.lang.php)
  • 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: Determine Which Checkboxes are Checked
    ... foreach (DataListItem item in DataList1.Items) ... with checkboxes based on the contents of a SQL table. ... I know I've seen some nice tight routines to ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Any Help? Stuck trying to create cgi perl program
    ... fills out textboxes and checkboxes while the program places the values ... from the text and checkboxes into a .csv file. ... foreach my $p ) { ...
    (comp.lang.perl.misc)
  • Re: Any Help? Stuck trying to create cgi perl program
    ... fills out textboxes and checkboxes while the program places the values ... from the text and checkboxes into a .csv file. ... foreach my $p ) { ...
    (comp.lang.perl.misc)