Why does the following code skip the if function (in red) and go straight to the else (in blue)?
<script src="SpryAssets/SpryAccordion.js" type="text/javascript"></script>
<link href="SpryAssets/SpryAccordion.css" rel="stylesheet" type="text/css">
<?php
$time = date("G");
if ($time <= 23 && $time > 8){
?>
<div id="Accordion1" class="Accordion" tabindex="0">
<div class="AccordionPanel">
<div class="AccordionPanelTab">Starters</div>
<div class="AccordionPanelContent">
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("christos_ncg_west") or die(mysql_error());
$result = mysql_query("SELECT * FROM starters")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>Item</th> <th>Price</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['item_name'];
echo "</td><td>";
echo $row['price'];
echo "</td></tr>";
}
echo "</table>";
?>
</div>
</div>
</div>
<?php
} else {
echo "Online ordering is not available at this time.";
}?>
<script type="text/javascript">
<!--
var Accordion1 = new Spry.Widget.Accordion("Accordion1");
//-->
</script>
Having problems with my if
Moderator: General Moderators
Re: Having problems with my if
you may have to make the $time in to a Integer
cause the if statement is comparing strings
or a single "&" might work
cause the if statement is comparing strings
or a single "&" might work