To display a field from databse and calculate time different

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bakarre
    New Member
    • Jun 2007
    • 8

    To display a field from databse and calculate time different

    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("SE LECT 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_arr ay($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! ";
    }
    }
    ?>
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to PHP forum.

    Comment

    • Bakarre
      New Member
      • Jun 2007
      • 8

      #3
      Originally posted by debasisdas
      Question moved to PHP forum.
      Still waiting for your input

      Comment

      • nathj
        Recognized Expert Contributor
        • May 2007
        • 937

        #4
        Originally posted by Bakarre
        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("SE LECT 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_arr ay($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

        Comment

        • Bakarre
          New Member
          • Jun 2007
          • 8

          #5
          Hi, Thanks alot friends, I was able to fix the problem.

          Comment

          • nathj
            Recognized Expert Contributor
            • May 2007
            • 937

            #6
            Originally posted by Bakarre
            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

            Comment

            Working...