Posted by Jamsi in
PHP on February 7th, 2006 |
5 responses
I noticed the lack of tutorials or articles when using checkboxes in a dynamic form, so I thought I’d post some code I used recently to manage deleting rows. The thing most people forget isthat the checkbox field name has to have a [] on the end as this tells PHP to use an array and not a normal variable to hold the information.
PHP
if ($_REQUEST["btnDelete"])
{
foreach ($_REQUEST["chkDelete"] as $value) {
echo $value;
}
}
HTML
Related posts:
- How to Bootstrap PHP Code
Receive Discounted Software
No bull. Want cheap discounts for common software products?
- AntiVirus
- Video editing tools
- Web development tools
- Registry Cleaners
- Computer speed boosters!
Our editors get these products sent to us WEEKLY for review.
WE WANT TO PASS THESE DISCOUNTS ON TO YOU!
(We honestly don't need them)
So whack your email in the box below and when we receive stuff we'll forward it to you! Its that simple.
Leave a Reply
Thanks.
It worked like this for me
if ($_REQUEST["chkDelete"])
{
foreach ($_REQUEST["chkDelete"] as $value)
{
echo $value;
}
}
Whoops, thanks! Forgot a bracket
Help me please!
What table structure i must have?
I have:
`userid` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`visable` tinyint(1) NOT NULL default ‘1′,
and trying (my lines 28,29):
echo ” “;
echo ” “.$row[username].”";
and having next error”
Notice: Use of undefined constant visable – assumed ‘userid’ in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-check-add.php on line 28
Notice: Use of undefined constant username – assumed ‘username’ in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-check-add.php on line 29
I whant to change visable value from 1 to 0 if checkbox is not checked. Plz, help, i am newbie…
Best places to play, best strategies to win. Player ratings & reviews of top online casinos & pokers with highest payouts & biggest bonuses.
Yep man, thanks,
if ($_REQUEST["btnDelete"]) {
.
.
.
}
Was what I need, otherwise it doesn’t show the correct value.
All the best