timeDiff function
Posted: Tue Jan 31, 2012 2:43 am
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`)]."
}
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`)]."
}