Jump to content

count number of updates


phppup

Recommended Posts

I got to thinking late last night (which generally leads to trouble), so please be gentle if some educating is in order, as I suppose I will touch a few related issues.

 

As I develop my database, I will include two seperate columns.  One for the time/date that an order was placed.

A second for the time/date that an order is updated (unless there's a better way, please inform me).

 

I pressume that if a record is updated several times, it will continually overwrite the time/date to the point that I will only see the latest update.  Now I was wondering if I could create a third column to keep count of the number of times a record had been updated, so if it were altered 16 times, I would know when the last update occurred, and have the count number also.

 

Will something like this coding work?

 

SELECT updates FROM myTable WHERE id="$id"

$updates =n

if n<1, n=1

}else{ n++

 

Link to comment
https://forums.phpfreaks.com/topic/258137-count-number-of-updates/
Share on other sites

  Quote

Isn't that what I did.

Are you trying to be a wiseguy and waste my time, or do you have an actual solution to suggest to improve my code?  If so, please POST IT!

 

I'm not going to write code for you, sorry. If you already did it, then this topic is finished.

I think you should increment a field every time an UPDATE query is executed. It can all be done at one time; there's no need for a SELECT query ahead of time. The syntax is here: http://dev.mysql.com/doc/refman/5.0/en/update.html in the third grey highlighted code block.

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.