Below is a php code i made in a non codeigniter code work. It is a check all and uncheck all delete function. i’m not sure where to put this if it’s in the control model or view? can anyone please help me.
<?php
/*Check Box Commands*/
$id=$row_notification['user_id'];
if(isset($_POST['Delete'])) {
$checkbox = $_POST['checkbox'];
mysql_select_db($database_connection_ched, $connection_ched);
$id=$row_notification['user_id'];
for($i=0;$i<count($checkbox);$i++)
{
$delete = "DELETE FROM tb_user WHERE user_id=$checkbox[$i]";
mysql_query($delete,$connection_ched);
}
$result2 = mysql_query($delete);
if($result2)
{
echo "[removed]alert ('Successfully Deleted');[removed]";
echo "<meta http-equiv=\"refresh\" content=\"0;URL=notification.php?\">"; }
}
?>
You should not be using “meta refresh” for redirection.
Use PHP’s header function:
You should put that code in your Controller.
Example:
And small piece of advice:
You do not have to notify anyone via JavaScript’s alert function when something is deleted, inserted, altered or anything alike. Alert is a bit anoying.
Also, checkout these links:
That should help you get a more clearer picture how MVC works, and how CodeIgniter works.