PHP mysqli insert update delete for Dynemic query

PHP mysqli insert update delete for Dynemic query

Today, We want to share with you PHP mysqli insert update delete for Dynemic query.
In this post we will show you PHP mysqli insert update delete for Dynemic query, hear for PHP mysqli insert update delete for Dynemic query we will give you demo and example for implement.
In this post, we will learn about PHP mysqli insert update delete for Dynemic query with an example.

Create-Read-Update-Delete(CRUD) statement query operation by using MySQLi statement way in the PHP.

The CRUD stands for simple Means Create statement, Read statement, Update statement and Delete statement database records. Add record, Edit record, Update record, and Delete record functionality is used almost web-applicaton or any dynamic webapps every web project in PHP.

ng4free.com In this Post Give to , PHP CRUD operations using MySQLi more simple and easy to user-friendlyinsert update delete in php mysqli with example

Three SQL commands Like as a – (INSERT, UPDATE and DELETE)– Main usually form the simple of any dynamic content management system.

Create Insert Query for dynamic Database

 $pname ,
				'lid'=>$lsid,
				'ptitle' => $ptitle,
				'pkeywords' => $keywords,
				'purl' => 	'',
				'pdesc' => $pagedesc
				);
	$columns = array_keys($arr);
	$values = array_values($arr);
	$str = $db->query("INSERT INTO $tablename (".implode(',',$columns).") VALUES ('" . implode("', '", $values) . "' )");

}
?>

Create Update Query for dynamic Database

 $pname ,
				'ptitle' => $ptitle,
				'pkeywords' => $keywords,
				'pdesc' => $pagedesc
				);	
    $query = "UPDATE $tablename SET";
	$comma = " ";
	foreach($arr_data as $key => $val) {
		if( ! empty($val)) {
			$query .= $comma . $key . " = '" . mysql_real_escape_string(trim($val)) . "'";
			$comma = ", ";
		}
	}
	$query .=" where status=1 and pid='$emid'";
	$sql = $db->query($query);

}
?>

DELETE Query for dynamic Database

Delete Page";

$id = $db->real_escape_string($_GET['id']); 
$db->query("DELETE FROM items WHERE id='$id'");
?>

DELETE Query for dynamic Database

$value) {
        $exp[$i] = $key." = '".$value."'";
        $i++;
    }

    $sexper = implode(" AND ",$exp);
    if(mysqli_query($db,"DELETE FROM $tablename WHERE $sexper")){
        if(mysqli_affected_rows($db)){
            echo "deleted successfully
"; } else{ echo "want to the delete is no loger exists
"; } } else{ echo "Generate Error deleting for all the data: " . mysqli_error($db); } } ?>

View Demo

We hope you get an idea about PHP mysqli insert update delete for Dynemic query
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.

Leave a Comment