mysqli insert into table only if not exists
I need to insert a record into a database table only if title field doesn't match one that already exists in the DB.
<?php
include ('common/connection.php');
if(!empty($_REQUEST['submit']))
{
$title=$_REQUEST['title'];
$com=$_REQUEST['comment'];
if(!empty($_REQUEST['editid'])){
$id=$_REQUEST['editid'];
$query="update namedb set
title='$title',comment='$com' where id=$id";
header('location:all_category.php');
}else{
$query="INSERT INTO namedb (title,comment) values
('$title','$com')";
}
mysqli_query($connect,$query);
}
?>
Subject
Written By
Posted
mysqli insert into table only if not exists
August 13, 2017 12:52AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.