katlees
asked on
How to list next 12 months
I had someone write up this code for me. It works great except for when it displays the second line of the next twelve months, it starts that line with a |
So it looks like
May 09 | Jun 09 | Jul 09 | Aug 09 | Sep 09 | Oct 09
| Nov 09 | Dec 09 | Jan 10 | Feb 10 | Mar 10 | Apr 10
How can I remove the | before the start of the second line so it looks like
May 09 | Jun 09 | Jul 09 | Aug 09 | Sep 09 | Oct 09
Nov 09 | Dec 09 | Jan 10 | Feb 10 | Mar 10 | Apr 10
So it looks like
May 09 | Jun 09 | Jul 09 | Aug 09 | Sep 09 | Oct 09
| Nov 09 | Dec 09 | Jan 10 | Feb 10 | Mar 10 | Apr 10
How can I remove the | before the start of the second line so it looks like
May 09 | Jun 09 | Jul 09 | Aug 09 | Sep 09 | Oct 09
Nov 09 | Dec 09 | Jan 10 | Feb 10 | Mar 10 | Apr 10
<?php
for ($i = 0; $i < 12; $i++)
{
$echo_date = date("M y", mktime(0, 0, 0, date("m") + $i + 1, 1, date("Y")));
$link_date = date("mY", mktime(0, 0, 0, date("m") + $i + 1, 1, date("Y")));
echo "<a href=\"happening.php?monthdisplay=$link_date\"><font class=\"style8\"> $echo_date</font></a>\n";
if ($i == 5)
{
echo "<br />\n";
}
if ($i < 11)
{
echo " | ";
}
}
?>
ASKER
I get Parse error: syntax error, unexpected T_IS_NOT_EQUAL, expecting T_VARIABLE or '$' in /home/visitmit/public_html /happening .php on line 108
That line is
if ($i < 11 && $ != 5)
That line is
if ($i < 11 && $ != 5)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello,
Use this code:
Use this code:
<?php
for ($i = 0; $i < 12; $i++)
{
$echo_date = date("M y", mktime(0, 0, 0, date("m") + $i + 1, 1, date("Y")));
$link_date = date("mY", mktime(0, 0, 0, date("m") + $i + 1, 1, date("Y")));
echo "<a href=\"happening.php?monthdisplay=$link_date\"><font class=\"style8\"> $echo_date</font></a>\n";
if ($i == 5)
{
echo "<br />\n";
}
if ($i < 11 && $i!=5)
{
echo " | ";
}
}
?>
shobinsun, why would you post the exact same solution I just provided?
~A~
~A~
if ($i < 11)
{
echo " | ";
}
to this;
if ($i < 11 && $ != 5)
{
echo " | ";
}