This question already has an answer here:
Alright so I am trying to make a page in my Admin control panel where you can view if the site is under some sort of maintenance. I am having trouble, not sure if it's from MySQL end, human error, or PHP.
Here is my code
<?php
$getMaint = mysql_query("SELECT * FROM 'system'");
if($getMaint['maintenance'] == 1){ echo "<b align='center'>Maintenance is turned <j style='color:#00A808'>On</j></b>";
} else { echo "<b align='center'>Maintenance is turned <j align='center' style='color:#CC000A'>Off</j></b><br /><br /> "; }
?>
What I am getting on my end from it is either when having maintenance either 1 or 0 it shows Off no matter if in my database I change it from 0 or 1?
I am not sure if it's because the structure of maintenance number system is setup as a enum('0', '1')
What I want it to do is when maintenance is marked as 1 in database(MySQL) I want it to say On for maintenance or if 0 it will say Off.
---------------------------------Fixed---------------------------------------
My solution:
<?php
$getSystem = mysql_query("SELECT * FROM `system`");
while($Maint = mysql_fetch_array($getSystem))
{
if($Maint['maintenance'] == 1){ echo "<b align='center'>Maintenance is turned <j style='color:#00A808'>On</j></b>";
} else { echo "<b align='center'>Maintenance is turned <j align='center' style='color:#CC000A'>Off</j></b><br /><br /> "; }
}
?>
Thank you John Cone and juergen d
</div>