View Full Version : PHP/mySQL question
WLHosting.com
04-16-03, 04:11 PM
I am creating a php "jokes" script. It is a script that allows you to input your name and some text. I am working on an admin page and I cannot figure out how to make it so that you use a checkbox next to the results so that you can delete them out of the database. Can somebody help me out or tell me where to go for resources on this topic. It is like the delete link in phpmyadmin in the tables sections. Thanks for your time.
interactive
04-16-03, 05:34 PM
Here's how I use to do it. when you display your jokes in your admin cp or whatever you want to call it, I'm sure you're using a while loop or a for loop. If you are just use a variable and increment it every run through. Then with your checkbox go something like this:
print("<INPUT TYPE='checkbox' NAME='check_box[$increment_var]' VALUE='TRUE'>");
At the end of the form put a hidden variable (name example: total_checks) and go:
print("<INPUT TYPE='hidden' NAME='total_checks' VALUE='$increment_var'>");
Now that will tell the script the form posts to how many checkboxes there were.
Then on the script that it submits to just use another for loop like this:
for($i=0;$i<$total_checks;$i++)
{
if($check_box[$i])
{
//action you want to do here if checkbox is selected
}
}
Keep in mind I have a headache right now so that code not might work. There are tons of ways to do this but I found when I first started coding it was the easiest. If you need any more help hit me up on AIM (SN: ntwrkgur), post here, or PM me. Good luck.
vBulletin v3.5.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.