Jump to content

Recommended Posts

Hi all.

 

I'm a newbie to PHP and Mysql, and I hope you can help me.

I have a table called "jos_log", in that table I have a column called "total" which stores total time like this 14:00.

I need a PHP script that can sum that time column and display it in a text box called "total_time".

 

Looking forward to hear from someone :)

 

Cheers. Hasamba

Link to comment
https://forums.phpfreaks.com/topic/229622-sum-total-time-column-with-php/
Share on other sites

Hi,

 

The total field is also TIME.

I already have a PHP script that calculate startTime and endTime and gives me the Total for each row.

Now I need a PHP script that will automatic SUM the column Total in DB and will represented the SUM in a text field. The format should be HH:mm.

One thing I forgot to mansion! I'm doing this to save my Filght Time (I'm a Pilot). Which means, The SUM time is a lot higher the 24:00. Right now I have 60:00 hours.

 

Do you think I should move it to the PHP section?

No need to post in more than one forum, as it violates the forum rules and TOS. You can do this in the query without a problem.

 

SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(`total_time`))) FROM `table` WHERE . . . 

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.