Welcome to Netrider ... Connecting Riders!

Interested in talking motorbikes with a terrific community of riders?
Signup (it's quick and free) to join the discussions and access the full suite of tools and information that Netrider has to offer.

MySQL/PHP help required

Discussion in 'The Pub' at netrider.net.au started by redrocket, Mar 23, 2006.

  1. anyone here with mysql knowledge?
    I have a mysql databse thats displays in a web page as a table, one of the columns is 'duration' (as in minutes & seconds).
    I want to display the total sum of this column, at the bottom of the page.
    So when you alter a duration in the field, it automatically adjusts the total duration at the bottom.
    the calculation must take into account it's dealing with time, not normal sum function.
    am i making sense? I am to me.

  2. So, what your displaying on the page is a representation of whats in the table?
    But these fields have to be editable, i assume to write back to the database later?
    If you are editing the values and needing it to update you need to actually code the webpage updating bit, and when you click save is when it will write it all to the database.

    I dont know of any auto functions of the top of my head, although try looking for a time() function and it might help, else can manually code the updating part.

    hope it helps, ask a bit more if you need more help. :)
  3. If your duration column is correctly defined as a time field...

    SELECT SEC_TO_TIME(SUM(TIME_TO_SEC('duration'))) AS duration_total FROM your_table {WHERE/GROUP_BY ...};

    output the result with your PHP, formatting appropriately.