Thursday, July 29, 2010

Delete More Records through check box?

ob_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="cms"; // Database name
//$tbl_name="test_mysql"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Select data from table..
$sql="SELECT * FROM data";
$result=mysql_query($sql);
extract($_POST);

$count =mysql_num_rows($result);

// Check if delete button active, start this
if(isset($_POST['delete'])){
    for($i=0;$i<$count;$i++){
        $del_id = $checkbox[$i];
        $sql = "DELETE FROM data WHERE id='$del_id'";
        $reslt = mysql_query($sql);
    }   
    // if successful redirect to delete_multiple.php
    if($reslt){
        header("location:deletemorerecords.php");
       
    }
}
mysql_close();
?>

1 comment:

Please Comment Here!

How to backup and download Database using PHP

< ?php $mysqlUserName = 'databaseusername' ; $mysqlPassword = 'databasepassword' ; $mysqlHostNa...