How to run or execute multi query in mysqli PHP

How to run or execute multi query in mysqli PHP

$conn = mysqli_connect("localhost","username","password","database_name");

/* Test Connection */
if (mysqli_connect_errno()) {
    printf("Your Connection failed: %s\n", mysqli_connect_error());
    exit();
}

$query = "DELETE FROM `demo_table` WHERE `mid`='$id';INSERT INTO `MyTable` (`firstname`, `lastname`, `emailid`)
VALUES ('Brain', 'Colls', '[email protected]')";

mysqli_multi_query($conn,$query); // Execute multi query at one time

 

Leave a Reply

Your email address will not be published. Required fields are marked *