Hey Y! Answers,
Small PHP problem, anyone have any ideas?
Let's say $currentHour is date("g"), or, right now, the numerical 1, because it is 1 PM.
I have hourValues("1"); and hourValues("2");
Why does hourValues("1"); not produce the " selected" from the if statement $currentHour == $thisHour (or, conversely, $thisHour == $currentHour), but $currentHour == "1" will produce the right result?
function hourValues($thisHour)
{
echo "<option value=\"".$thisHour."\"";
if($currentHour == $thisHour)
{
echo " selected";
}
echo ">";
echo $thisHour."</option>\r\n";
}
Small PHP problem, anyone have any ideas?
Let's say $currentHour is date("g"), or, right now, the numerical 1, because it is 1 PM.
I have hourValues("1"); and hourValues("2");
Why does hourValues("1"); not produce the " selected" from the if statement $currentHour == $thisHour (or, conversely, $thisHour == $currentHour), but $currentHour == "1" will produce the right result?
function hourValues($thisHour)
{
echo "<option value=\"".$thisHour."\"";
if($currentHour == $thisHour)
{
echo " selected";
}
echo ">";
echo $thisHour."</option>\r\n";
}