I want to update my database if ID is already exist else insert if ID is not exist.
process.php:
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "maindata";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("<center>Connection failed: " . mysqli_connect_error() . "</center");
}
$id = $_POST['id'];
$aname = $_POST['aname'];
$xsummary = $_POST['xsummary'];
$sql=mysql_query("SELECT * FROM info WHERE ID = $id");
if (mysql_num_rows($sql) == $id)
{
$sql="update info set AccountName= '$aname', ExecutiveSummary='$xsummary'";
}
else {
$sql="insert into AccountName= '$aname', ExecutiveSummary= '$xsummary'";
}
Some one help me on my problem.
Thanks in advance.