Jump to content

Current Status and Previous States where to start


ScoobyDont

Recommended Posts

HI All, 

 

Sorry for sounding crap but searching the net has come up with nothing and that's what I have nothing...and to be honest dont know where to start looking for what I need 

 

I will try and explain as best I can

 

In the db I have  current_status, this is updated from a select list in a form on website one

 

status 1 

status 2

status 3

etc etc

 

So when the user changes the "status" from website 1 it updates the database and shows the current status in website 2

 

What I want is to show the previous states with a time  stamp on when it was changed something like image attached

 

Am I right in thinking I will not be able to do this with only working with one row in the db or is this possible with php alone
 
Can someone give me a pointer where to start, I am not after anyone to write code just a little advice
 
Thanks in advance
 

 

post-203324-0-43515100-1487360669_thumb.jpg

Link to comment
Share on other sites

  • 3 weeks later...

Hi, 

 

I have managed to get it partially working but now stuck again, 

 

When I change the status the time changes in the db..which is what I wanted

 

I will now try and explain what I want to do next 

 

When I change from Status 1 to Status 2 is it possible to grab the time of status change and make it static so it wont change when the status alters in the db again from 2-3

 

post-203324-0-73110600-1488738961_thumb.jpg

 

Will I need another column in the db or is there something I can do with php

 

Thanks in advance

Link to comment
Share on other sites

Hi, 

Sorry lost you a little, this is the db

 

post-203324-0-08168200-1488743458_thumb.jpg

 

Obviously it has'insert_time' and 'update_time' which is all well and good

 

I am struggling to understand or get to grips with what I have to do to keep 'update_time' static for front end as like my image in OT

 

What I want is:-

 

Previous States

status 1 = updated @ 20.09

 

Current State

status 2 = updated @ 20.11

 

But currently if I changed the status to 2 I would get this results

 

Previous States

status 1 = updated @ 20.11

 

Current State

status 2= updated @ 20.11

 

Would I be best to do 'fwrite' to a new file or is there another way

Link to comment
Share on other sites

CREATE TABLE `status_log` (
  `status_log_id` int(11) NOT NULL AUTO_INCREMENT,
  `item_id` int(11) DEFAULT NULL COMMENT 'id of item owning the status',
  `status` tinyint(4) DEFAULT NULL,
  `changed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`status_log_id`)
) ;

When the status changes, add a new record

mysql> select * from status_log;
+---------------+---------+--------+---------------------+
| status_log_id | item_id | status | changed             |
+---------------+---------+--------+---------------------+
|             1 |       1 |      1 | 2017-02-28 15:03:00 |
+---------------+---------+--------+---------------------+

-- add new record

mysql> INSERT INTO status_log (item_id, status) VALUES (1,2);

-- now you have

mysql> select * from status_log;
+---------------+---------+--------+---------------------+
| status_log_id | item_id | status | changed             |
+---------------+---------+--------+---------------------+
|             1 |       1 |      1 | 2017-02-28 15:03:00 |
|             2 |       1 |      2 | 2017-03-05 21:08:43 |
+---------------+---------+--------+---------------------+
  • Like 1
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.