Reply to Re: Iterate Through Values from All Checked Checkboxes

Your name:

Reply:


Posted by Kimmo Laine on 12/11/06 08:33

"ameshkin" <amir.meshkin@gmail.com> wrote in message
news:1165824818.607980.231200@l12g2000cwl.googlegroups.com...
> What I want to do is very simple, but I'm pretty new at PHP and its a
> little hard for me.
>
> I have one page, where there are a rows of checkboxes. A button
> selects all checkboxes, and then presses delete.
>
> When delete is pressed, I want to go to a next page and run a sql
> command for every single box thats checked. The checkboxes store a
> value, and multiple boxes can be checked.
>
> On the second page, whch is the form actin, I simply want to iterate
> through and pull which values are checked and run a sql command for
> each value.
>
> I have no idea how to do this. I assume you willl have to use a for
> each statement, but am having trouble programming this.
>
> Someone please help!
>

Name the checkboxes using an array:
<input type="checkbox" name="delete[]" value="100" /> 100
<input type="checkbox" name="delete[]" value="200" /> 200

Then in the form handler iterate thru the array:
foreach($_POST['delete'] as $key => $val){
// SQL magic to delete $val
}

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация