Having problems with my if

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
achilles1971
Forum Newbie
Posts: 3
Joined: Wed Sep 01, 2010 9:11 pm

Having problems with my if

Post by achilles1971 »

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>
natdrip
Forum Newbie
Posts: 7
Joined: Tue Aug 31, 2010 4:51 pm

Re: Having problems with my if

Post by natdrip »

you may have to make the $time in to a Integer
cause the if statement is comparing strings
or a single "&" might work
Post Reply