My insert database i have a table named:
table1 with 4 columns
user | id | roll |class
I have 2 php files table1.php
and newadd.php
. I have inserted user
, id
, class
value in table1
via table1.php
.
I want to insert class value
in same table via newadd.php
, but when I run the files from localhost values are inserted perfectly, but in different row, not in same row.
My query is:
INSERT INTO table1 (class) VALUES ('two') WHERE id=123;
but it is not working..what should i do?
Here is my code
<?php
include('insertjoincon.php');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO table1 (class)
VALUES ('two') WHERE id=123";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>