By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

To display a field from databse and calculate time different

P: 8
Good day,
i have problem to display a field from databse and calculate time different.
See below my code.

I hope somebody can fix the problem for me.

<?php
$db = mysql_connect("localhost", "****", "********");
mysql_select_db("FDP",$db);
if (isset($_POST['clearance']))
{
$result = mysql_query("SELECT cs, tac, eta, eat, fl, du FROM aeroarrival WHERE DATE = current_date and TIMEDIFF( eta, current_time ) <= '00:30:00' as tmdif
ORDER BY ETA",$db);
$myrow = mysql_fetch_array($result)

echo ($row['CS']);
echo ($row['tmdif']);

$CTIME1 = DATE('H : i : s');
$CTIME = $CTIME1 - $EAT;
//echo 'cs';
if ($CTIME < '00:15:00')
echo "DontClear!";
elseif ($CTIME < '00:20:00')
echo "SemiClear!";
else if ($CTIME > '00:20:00')
echo "Clear!";
else {
echo "GoodClear!";
}
}
?>
Feb 7 '08 #1
Share this Question
Share on Google+
5 Replies


debasisdas
Expert 5K+
P: 8,127
Question moved to PHP forum.
Feb 7 '08 #2

P: 8
Question moved to PHP forum.
Still waiting for your input
Feb 7 '08 #3

nathj
Expert 100+
P: 938
Good day,
i have problem to display a field from databse and calculate time different.
See below my code.

I hope somebody can fix the problem for me.

<?php
$db = mysql_connect("localhost", "****", "********");
mysql_select_db("FDP",$db);
if (isset($_POST['clearance']))
{
$result = mysql_query("SELECT cs, tac, eta, eat, fl, du FROM aeroarrival WHERE DATE = current_date and TIMEDIFF( eta, current_time ) <= '00:30:00' as tmdif
ORDER BY ETA",$db);
$myrow = mysql_fetch_array($result)

echo ($row['CS']);
echo ($row['tmdif']);

$CTIME1 = DATE('H : i : s');
$CTIME = $CTIME1 - $EAT;
//echo 'cs';
if ($CTIME < '00:15:00')
echo "DontClear!";
elseif ($CTIME < '00:20:00')
echo "SemiClear!";
else if ($CTIME > '00:20:00')
echo "Clear!";
else {
echo "GoodClear!";
}
}
?>

Hi,

Where are DATE, current_date and current_time defined?

It looks like you are heading in the right direction but these items look a bit odd to me. If you want to use the current date in the where clause now() works really well.

Cheers
nathj
Feb 7 '08 #4

P: 8
Hi, Thanks alot friends, I was able to fix the problem.
Feb 8 '08 #5

nathj
Expert 100+
P: 938
Hi, Thanks alot friends, I was able to fix the problem.
Hi,

Glad to hear you got it working - what was the solution in the end?

nathj
Feb 8 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.