Jump to content

last updated and created dates


Ollifi

Recommended Posts

by running the following code, you will create two datetime columns.

1. is the time it was create

2. is the time it was last updated.

 

When you insert a new row, you need to use MySQL's now() function for the date_add column, the date_update column will automatically create a timestamp

 

alter table some_table add column  date_add datetime null, date_updated timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;

ok thank you for help

could you say whats wrong with this

$query      = "UPDATE tolkit SET (lyhenne, nimi, kpl, ostopaikka, valmistaja, lisatty, paivitetty) VALUES ('".$lyhenne."', '".$nimi."', '".$kpl."', '".$ostopaikka."', '".$valmistaja."', '".$lisatty."', '".$paivitetty."') WHERE id='".$id."'";

Because an update query is in this format:

$lyhene = mysql_real_escape_string($_POST['lyhene']);
$nimi= mysql_real_escape_string($_POST['nimi']);
$id = (int)$_POST['id'];
$query =  "update tolkit set lyhenne = '$lyhene', nimi = '$nimi' ... where id = $id;";

ok,thanks for helping

I think i´ll not need mysql_real_escape_string

 

but btw

when I remove many rows from table and i have AUTO INCREMENT in ID field why the ID is not next to existing ones , it´s next to previous ones ? i think you may not understand

but

ids: 1,2,3,4,5

then remove 4,5

then create new and it gots id 6

how can i make it to got id 4 ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.