RE: checkboxes and loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am relatively new with PHP, but have done this many times with ASP.
First, I would not assign the counter value to the checkbox as you are now.
Use the ID (identity) value from the database for the applicant record
instead.  Since ONLY the checkboxes that are checked will be submitted, you
can just loop through the submitted checkbox values and perform a 'delete',
or 'whatever' on each submitted record.  Or, use: "...WHERE IN (id1, id2,
..., idN)" in your DELETE statement.

Duane



> -----Original Message-----
> From: matthew perry [mailto:mwperry@xxxxxxxxxxx]
> Sent: Sunday, March 28, 2004 11:45 PM
> To: php-db@xxxxxxxxxxxxx
> Subject:  checkboxes and loops
>
>
> OK lets see if I can figure out how to ask this:
>
> I am setting up a system for my company to filter through employee
> applications.  Most of the applications do not fit the criteria and I
> want to allow my bosses a checkbox to the right of them which
> they can
> check or uncheck to remove an applicant.
> So I run a loop that generates a bunch of check boxes with the name
> box1, box2, box3... by running a loop that runs this and increments
> counter every time:
> {
> <input type = "checkbox" name = "box<?echo $counter;?>" value
> = "delete">
> $counter++;
> }
>
> But when I try to create my query that updates the table I have a
> problem generating these variable again by referring to them
> indirectly:
>
> *********Bad solution 1 (to much work)***********
> if ($box1 == 'delete')   <<do whatever>>
> if ($box2 == 'delete')  <<do whatever>>
> if ($box3 == 'delete')  <<do whatever>>
> if ($box4 == 'delete')  <<do whatever>>
> if ($box5 == 'delete')  <<do whatever>>
> if ($box6 == 'delete')  <<do whatever>>
> *******************************************
>
> *********Bad solution 2 (doesn't work)***********
> $counter = 1;
> while (<<whatever>>)
> {
> if ($box . $counter == 'delete')   <<do whatever>>
> $counter++;
> }
> *******************************************
>
> How do I get around this problem?
> Hopefully someone understands what I am trying to say.
>
> Matt
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux