/    Sign up×
Community /Pin to ProfileBookmark

Multiple checkboxes in form

Hi guys & girls

I’m pretty new to the whole PHP thingy and I’m kinda stuck atm. I created a loop which pulls data from my database and inserts it into a table, every row also adds a checkbox. My aim is that if the user checks the checkbox and clicks delete that it must delete the entry from my database. My code

[code=php]function delete_course() {
global $connection;
$manages = “SELECT * FROM course ORDER BY cid ASC”;
$tables = mysql_query($manages, $connection) or die (“Database course query failed: ” . mysql_error());
$num = mysql_num_rows($tables);
$i = 0;

while ($i < $num) {
$row = mysql_fetch_array($tables);
$cid = $row[‘cid’];
$cname = $row[‘cname’];

echo ‘<form action=”delete_course.php” method = “post”><input type=”hidden” name=”cid” value=”‘.$row[‘cid’].'”/></td>’;echo $row[‘cid’];
echo ‘<tr>’;
echo “<td align = ‘left’><input type = ‘checkbox’ name = ‘checkbox[]’></type>” .$row[‘cid’]. ” – ” . $row[‘cname’].”</td>”;
echo ‘</tr></form>’;
$i++;
}
//echo “<br />”;
if (isset($_POST[‘del’])) {
if (isset($_POST[‘cid’])) {
}
}
/* $qry = “DELETE FROM course WHERE cid = $_POST[cid]”;
$result = mysql_query($qry, $connection) or die (“Database course delete query failed: ” . mysql_error());
$increment = “ALTER TABLE course AUTO_INCREMENT = 1”;
$inc_reset = mysql_query($increment,$connection) or die (“Could not reset auto increment: ” . mysql_error());
header(“location:man.php”);*/
//echo “yo”;
// } else {
// echo “no”;}
}
[/code]

my problem is this line

[code=php]if (isset($_POST[‘cid’])) {[/code]

Any suggestions would be greatly appreciated. ?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @shelv spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...