如何在phpmyadmin和MySQL中创建插入和更新列? [关闭]

I need to have one table column that is going to record time and date when row has been inserted, and one when it was updated.

What is a best way to achieve this, and that is compatible with MySQL 5.5, 5.6, 5.7 versions ?

Also, how I can set everything in phpmyadmin ? Do I have to chose date or date and time -> timestamp as a column type ? And then what ?

I couldn't find any tutorial about this.

Your database should have timestamp column to record last update timestamp and DATETIME column to insert the date record was inserted.

CREATE TABLE `table` (
  `record_inserted` DATETIME, 
  `last_updated` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
)
ENGINE = InnoDB;

Well having a colomn that inserts a date on creation is one way to do it then if you create a second column through php. collect the date and when you add or modify somthing have the php put the current date into the 2nd colomn

e.g.

$modifydate = Date('l jS \of F Y h:i:s A');

$conn = new mysqli(HOST,USER,PASSWORD,DATABASE);
if ($conn->connect_error)
{
    die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO TABLE (DateModified,othercolomns) VALUES ('$modifydate ', '$othervalues')";

if ($conn->query($sql) === TRUE)
{
    echo "New record created successfully";
}
else
{
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();

SQL Table

Datecreated, DateModyfied, [other colomns]