OK, I've been trying to work out how elseif works. Read lots of tutes but here’s where I’ve got to and hopefully this will work.
Lets say that each day of the week I want to place a notice on my home page about when UK Markets take place:
The notices would be as follows:
- Mon = It Is London Market Day Today!
- Tue = The next weekly market in UK is tomorrow in Glasgow!
- Wed = It Is Glasgow Market Day Today!
- Thu = The next weekly market in UK is tomorrow in Cardiff!
- Fri = It Is Cardiff Market Day today and Leeds Market Day tomorrow!
- Sat = It Is Leeds Market Day Today!
- Sun = The next weekly market in UK is tomorrow in London!
What I need to know is - would this code actually do that?
<?php
$d=date("D");
if ($d=="Mon")
echo "It Is London Market Day Today!";
elseif ($d=="Tue")
echo "The next weekly market in UK is tomorrow in Glasgow!";
elseif ($d=="Wed")
echo "It Is Glasgow Market Day Today!";
elseif ($d=="Thu")
echo "The next weekly market in UK is tomorrow in Cardiff!";
elseif ($d=="Fri")
echo "It Is Cardiff Market Day today and Leeds Market Day tomorrow!";
elseif ($d=="Sat")
echo "It Is Leeds Market Day Today!";
elseif ($d=="Sun")
echo "The next weekly market in UK is tomorrow in London!";
?>
- <?php
- $d=date("D");
- if ($d=="Mon")
- echo "It Is London Market Day Today!";
- elseif ($d=="Tue")
- echo "The next weekly market in UK is tomorrow in Glasgow!";
- elseif ($d=="Wed")
- echo "It Is Glasgow Market Day Today!";
- elseif ($d=="Thu")
- echo "The next weekly market in UK is tomorrow in Cardiff!";
- elseif ($d=="Fri")
- echo "It Is Cardiff Market Day today and Leeds Market Day tomorrow!";
- elseif ($d=="Sat")
- echo "It Is Leeds Market Day Today!";
- elseif ($d=="Sun")
- echo "The next weekly market in UK is tomorrow in London!";
- ?>
If that works - how about this:
Let’s say I want to create a new notice every hour. I tried this code and it definitely does not work:
<?php
$d=h:i A ("h:i A");
if ($d>="06:00")
echo "It Is Between 6 and 7";
elseif ($d>="07:00")
echo "It Is Between 7 and 8";
elseif ($d>="08:00")
echo "It Is Between 8 and 9";
elseif ($d>="09:00")
echo "It Is Between 9 and 10";
else echo “What time is it?”;
?>
- <?php
- $d=h:i A ("h:i A");
- if ($d>="06:00")
- echo "It Is Between 6 and 7";
- elseif ($d>="07:00")
- echo "It Is Between 7 and 8";
- elseif ($d>="08:00")
- echo "It Is Between 8 and 9";
- elseif ($d>="09:00")
- echo "It Is Between 9 and 10";
- else echo “What time is it?”;
- ?>
What am I doing wrong?... apart from being dumb.
Thanks