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”;}
}
my problem is this line
[code=php]if (isset($_POST[‘cid’])) {
Any suggestions would be greatly appreciated. ?