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;

Link to comment
Share on other sites

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."'";

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.