[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to list next 12 months

Posted on 2009-04-07
5
Medium Priority
?
976 Views
Last Modified: 2013-12-13
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

<?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 " | ";
								}
	}
							?>

Open in new window

0
Comment
Question by:katlees
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 12

Expert Comment

by:Richard Davis
ID: 24088500
change this;

if ($i < 11)
{
  echo " | ";
}

to this;

if ($i < 11 && $ != 5)
{
  echo " | ";
}
0
 

Author Comment

by:katlees
ID: 24088567
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)
0
 
LVL 12

Accepted Solution

by:
Richard Davis earned 2000 total points
ID: 24088682
Ooops! Sorry...typo

if ($i < 11 && $i != 5)

~A~
0
 
LVL 14

Expert Comment

by:shobinsun
ID: 24088743
Hello,

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 " | ";
                                                                }
        }
                                                        ?>

Open in new window

0
 
LVL 12

Expert Comment

by:Richard Davis
ID: 24088820
shobinsun, why would you post the exact same solution I just provided?

~A~
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question