Jump to content

storing values to table


atomsk

Recommended Posts

Ok i got this little script that fetches some data from mdl_table (in unix time format) makes a caclulation and creates a new variable $sessiontime (covnerts it to $time for readable user format). I created a sessiontime column in my database and I want to store the data from that variable to that column. $sessiontime is dynamically updated everytime lastaccess and lastlogin does. Any ideas where I start ?

 

 

<html>
<body>
    <table border="3" cellspacing="3" cellpadding="6">
            <tr>
                <td>
                    Firstname
                </td>
                <td>
                    Session Time
                </td> 
                <td>
                  	Session Date
                </td>
            </tr>
<?php
require_once("../config.php");  //contains connection to database

        $query = "SELECT * FROM mdl_user";

        $result = pg_query($query);
        if (!$result) {
            echo "Problem with query " . $query . "<br/>";
            echo pg_last_error();
            exit();
        }

        while ($myrow = pg_fetch_assoc($result))
        {
          $sessiontime = $myrow['lastaccess'] - $myrow['lastlogin']; 
          $sessiondate = $myrow['lastaccess'];
          $time = gmdate("G\h i\m", $sessiontime);
          $date = date("F j, Y, g:i a", $sessiondate);
               
          printf ("<tr><td>%s</td><td>%s</td><td>%s</td></tr>", $myrow['firstname'], $time, $date);  
        }    
?>
        </table>
    </body>
</html> 

Link to comment
https://forums.phpfreaks.com/topic/44916-storing-values-to-table/
Share on other sites

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.