Link to home
Start Free TrialLog in
Avatar of rhinez0rz
rhinez0rz

asked on

TIMEDIFF: Good Way to Stop Negative Time from Showing (using php & mysql)

Could you tell me how I could stop showing the countdown of time on my webpage once the timer hits 0 seconds? The following IF statement in the body doesnt hide the timer once the time difference hits a negative value.

<?php
////Time Diff////////////////////////////////////////////////////////////////////////////////////////////////////
$query_Resource_Gold_time ="SELECT TIMEDIFF(upgrade_date, now())AS date_diff_gold
FROM tbl_resource_gold WHERE village_id = '" . $colname_Resource_Gold . "'";
$Resource_Gold_time = mysql_query($query_Resource_Gold_time, $Killercube) or die(mysql_error());
$Resource_Gold_time_result = mysql_fetch_array($Resource_Gold_time);

////Time Diff////////////////////////////////////////////////////////////////////////////////////////////////////
?>
  <p>Time to upgrade: <?php if ($Resource_Gold_time_result['date_diff_gold']<=0){ // Show if the timediff is =>0
                              echo $Resource_Gold_time_result['date_diff_gold'];
                              }?>
Avatar of rhinez0rz
rhinez0rz

ASKER

Got it -

$Resource_Gold_time_result['date_diff_gold']>='0'

I didnt use the single quotes around the 0, this appears to work.
If you've answered your own question, ask community support to paq and refund the points.
ASKER CERTIFIED SOLUTION
Avatar of CetusMOD
CetusMOD
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial