We help IT Professionals succeed at work.
Get Started

PHP Code assistance needed with code logic

error77
error77 asked
on
301 Views
Last Modified: 2012-05-12
Hi all,

I need assistance modifying the following code.

<?php $li_count = 0; 
	echo '<ul>';
    
	echo '<li><a href="#">One</a></li>';
    $li_count++;
	
	echo '<li><a href="#">Two</a></li>';
    $li_count++;
	
	echo '<li><a href="#">Three</a></li>';
	$li_count++;
	
	//Dynamic pages.
	
	if ($var1 == '1') {
		echo '<li><a href="#">Dynamic1</a></li>';
		$li_count++;
	}	
	
	
	//Area 2
	if ($li_count > 4) {
		echo '<ul>';
		echo '<li><a href="#">Sub One</a></li>';
		echo '<li><a href="#">Sub Two</a></li>';
		echo '<li><a href="#">Sub Three</a></li>';
		echo '</ul>';
	}
	
	echo '</ul>';
		 ?>

Open in new window

           

What I need it to do is the following:

If at any time $li_count is bigger than 4 then I just it to do Area 2. In other words the first 4 list items will show up as normal..all other items if more than 4 will do Area 2.

So, I need to code to check the total at all times and if more than 4 then you get the sub list for all lists after 4th.

Hope it makes sense, if not please let me know.

Thanks
Comment
Watch Question
Freelancer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE