473,473 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

phpmyadmin/MySQL - dynamic date field?

hph
Please be gentle; I am a relative newbie for php/MySQL, and most of what
I am doing is based on being self-taught using someone else's
well-written code, and my own googling the answers to my questions.

I'm doing a php/MySQL page that reads data out of a MySQL database.
Longer term, I'll do a data-entry screen allowing me to modify the
database or add new records. For now, I'm just using phpmyadmin to data
enter stuff.

Is there a way to set up a date field, Last_Update, that would
automatically update to today's date any time a record was added or
changed using phpmyadmin?

Not sure if I'm asking the question clearly. What I want would be that,
let's say that I add a new record today, April 23. The Last_Update
field for the record would automatically be April 23. If I go in and
modify and part of that record on April 29, Last_Update automatically
changes to April 29 for that record.

If that's not possible, then how in php/MySQL would I display on a web
page "Information last updated on mm/dd/yyyy" based on the contents of
the database?
Apr 23 '06 #1
2 6135
>I'm doing a php/MySQL page that reads data out of a MySQL database.
Longer term, I'll do a data-entry screen allowing me to modify the
database or add new records. For now, I'm just using phpmyadmin to data
enter stuff. Is there a way to set up a date field, Last_Update, that would
automatically update to today's date any time a record was added or
changed using phpmyadmin?


This is the purpose of the field type 'timestamp'. If you want
only the date portion, you can get it with date_format() in the
MySQL query.

The *first* timestamp field will be updated to the current time if
the record is changed, and that field isn't explicitly set. If a
record is inserted, the timestamp field will be the current time
unless another non-null value is explicitly inserted (insert null
or leave the field out of the field list for insert).

Leave off the "using phpmyadmin" part. You get that behavior if
the record is changed with a query, with or without phpmyadmin.
*Can* you modify just one field with phpmyadmin? If you type in
an explicit query, yes, if you use neato GUI stuff, you may be
setting all the fields you didn't change back to the values they
had before, which defeats the action of the timestamp.

Gordon L. Burditt
Apr 24 '06 #2
> Is there a way to set up a date field, Last_Update, that would
automatically update to today's date any time a record was added or
changed using phpmyadmin?


Simply use the MySQL field type of "TIMESTAMP" and set it to null on
any updates to the table... TIMESTAMP fields are automagically set to
the current time when the value passed to it is null.

PS this post should actually be on comp.databases.mysql. I don't care
much but some people in usenet are real pricks about stuff like this.

Apr 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: JimC | last post by:
I have PHP installed on a Windows XP platform using IIS as server. When updating a MySQL database field set to MEDIUMTEXT in phpMyAdmin, the transaction seems to fail if the text contains more...
1
by: Gordan | last post by:
Hi, I have a site written in PHP with MS SQL Server 2000 as the db backend. When the site was made there was no need for advanced banner rotation so a 10 line script was written and it served...
0
by: DH | last post by:
I must work with phpMyAdmin 2.6.0-pl3 installed on a client's Windows NT web server. I've not previously encountered options for charset and collation using phpMyAdmin, and am not sure what to set...
0
by: Gnarlodious | last post by:
This is some odd behavior, I'm hoping someone can explain. I have a TiBook running 4.0.17 and phpMyAdmin 2.5.5-pl1 where MySQL hostname is configured as "Gnarlodious-TiBook" (machinename). So...
2
by: Daniel Mercier | last post by:
Hi, I'm new to mysql and just installed phpmyadmin. Here is the versions info: System Linux linlyne.spider.sense 2.4.22-1.2199.nptl #1 PHP Version 4.3.8
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
0
by: NewbieSupreme | last post by:
I'm using PHPMyAdmin on an Apache2Triad install (latest version; 5.x.x, which installs PHP5 and PHPMyAdmin 2.8 as well). In Access, I exported a table to a text file, tab-delimited, text qualifyer...
10
by: farukcse | last post by:
Dear Sir, i am facing a encoding problem with MySQL data base and phpMyAdmin. i developed a form . From wher user can insert the Car plate No. to the MySQL database.Both of the php file for...
1
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.