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:
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