atomsk Posted March 30, 2007 Share Posted March 30, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.