473,724 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ 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 "Informatio n last updated on mm/dd/yyyy" based on the contents of
the database?
Apr 23 '06 #1
2 6154
>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
automaticall y 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
2876
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 than a few hundred characters. The update is actually made successfully, but afterwards, the server cannot locate the phpMyAdmin page as requested by the client browser. I get a "Page cannot be found" error. Clicking on Update from the browser...
1
3405
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 well for years but now there's a need for a much more powerful banner rotation. At first I thought to buy some banner management app but after some time I realized that phpMyAdmin is the best thing. The problem is PMA uses MySQL. I can install...
0
2382
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 "MySQL connection collation" for English-US type usage. The default MySQL charset: UTF-8 Unicode (utf8) I didn't notice this until exporting a backup, which for different tables is giving me different "CHARSET=latin1" values.
0
1497
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 far so good, all works OK. I have a Cube running 4.0.20 and phpMyAdmin 2.5.5-pl1 where MySQL hostname is configured as "Gnarlodious-Cube" (machinename). But now phpMyAdmin can't login, throwing error
2
9031
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
17667
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 Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
0
3474
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 of "none" (this is how I read to do it from newsgroups). When I use the Query window in phpmyadmin to import the text file, it waits a while, then returns an error: #1064 - You have an error in your SQL syntax; check the manual that...
10
12765
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 inserting and veiwing is encoded in UTF-8 format. suppose i want to insert plate no as . 1 2 3 ص ص ص ص but i after inserting to the database i see the plate no as 1 2 3 ق ق ق ق in the database . In Database the plateno field's collation is...
1
9579
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 things (stored procedures, functions).. we have to manually edit. That time, we face some interesting challenges.. I failed to document all of them, but whatever I can share with u.. I will try.. :) ...
0
8741
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9389
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9160
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9090
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6689
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5996
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4771
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3210
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2149
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.