Unique Checkboxes!?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Lang
Forum Newbie
Posts: 5
Joined: Sun Oct 30, 2005 9:41 pm
Location: Smiths Falls
Contact:

Unique Checkboxes!?

Post by Lang »

OK, i'm making a forum, and i'd like to allow myself and moderators to delete multiple posts at a time, using checkboxes.
First I thought making the checkbox name the post subject, or the post ID. However that wou;dn't work 'cause then i'd need to know the ID ect ect and create a whole bunch of problems. Does anyone have an idea as to how I can do this?

Thanks in advance,
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

their names can all be the same "delete[]" for instance, their values should be the post id's .. you already have the information, so it's not a stretch to use them..
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Hi, when I first stumbled across this same situation, I was always a little lost as to what people meant, so I'd thought I would add a lil' summin to help clarify :)

Code: Select all

<?php

if (isset($_POST['delete'])) {

	foreach ($_POST['delete'] as $del) {
		echo "$del<br />\n";
	}

} else {

echo "<html>
	<head>
		<title>Testing..</title>
	</head>
	<body>
		<form method=\"post\" action=\"\">
			<input type=\"checkbox\" name=\"delete[]\" value=\"1\" /><br />
			<input type=\"checkbox\" name=\"delete[]\" value=\"2\" /><br />
			<input type=\"checkbox\" name=\"delete[]\" value=\"3\" /><br />
			<input type=\"checkbox\" name=\"delete[]\" value=\"4\" /><br />
			<input type=\"checkbox\" name=\"delete[]\" value=\"5\" /><br />
			<input type=\"submit\" value=\"Submit\" />
		</form>
	</body>
</html>\n";

}

?>
:)
Lang
Forum Newbie
Posts: 5
Joined: Sun Oct 30, 2005 9:41 pm
Location: Smiths Falls
Contact:

Post by Lang »

Thanks, guys.
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

there is a nice tutorial in the tutorial section
Post Reply