I have a table
id name stime etime
1 kip 10:10:00 11:10:05
2 too 10:15:05 11:15:00
3 bii 10:25:25 12:00:08
Am using the timediff() function in mysql I just want to display the name & time taken to run. How should I write the echo statements? its working on mySQL but has problems running php
The echo code below only echos the names but doesn't echo duration taken.
<?php
$con = mysql_connect("localhost","root");
$db = mysql_select_db("irun",$con);
$sql = mysql_query("select names, timediff(`etime`,`stime`) from irunner");
while($row=mysql_fetch_array($sql))
{
echo "".$row['names']."";
echo "".$row[timediff(`etime`,`stime`)]."
}
timeDiff function
Moderator: General Moderators
Re: timeDiff function
It only echoes the column names but doesnt work out the time difference between start and end time.
-
Robertology
- Forum Newbie
- Posts: 3
- Joined: Fri Jan 27, 2012 11:31 am
Re: timeDiff function
It is sometimes easier to alias a column in a situation like that.
Then you can reference it like so
Code: Select all
select names, timediff(`etime`,`stime`) as time_diff from irunnerCode: Select all
$row['time_diff']