PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 13th, 2012, 01:16 AM
lordrt21's Avatar
lordrt21 lordrt21 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 212 lordrt21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 9 h 39 m 19 sec
Reputation Power: 4
Exclamation Add a line break automatically after a specific count for a table's elements

Hello, I have a code which is automatically adding values using the th tag, and would like to insert a line break automatically after the 4th th is met, and then on the new line continue adding the values. My sample code is as follows:

PHP Code:
<table class="map-view"> <thead> <tr> <?php  foreach($rootMenus as $rootMenu) { $item cGetItemMenu($_SESSION['IDLANG'], $rootMenu['IDMENU']); ?> <th> <?php if($item != null) { switch($item[0]['IDITEMTYPE']) { case 5?> <a href="#" onclick="<?php echo $item[0]['CONTENT'];?>"><?php echo $rootMenu['TITLE']; ?></a> <?php break; case 6:$infoModule cGetInfoModClients($item[0]['IDLINK']);  if(!empty($infoModule)) { switch($infoModule[0]['CODE']) { case "PATHCONTROLLER" : echo getURLRewriting($item[0]['IDITEMTYPE'], $_SESSION['IDLANG'], $infoModule[0]['IDCLIENTMODULE'], $infoModule[0]['NAME'], $rootMenu['TITLE']); break; case "JSPOPUP" ?> <a href="#" onclick="<?php echo $infoModule[0]['ACTION'];?>"><?php echo $rootMenu['TITLE']; ?></a> <?php break; } } break; default: echo getURLRewriting($item[0]['IDITEMTYPE'], $_SESSION['IDLANG'], $item[0]['IDITEM'], $item[0]['TITLETRANSLATION'], $rootMenu['TITLE']); break; } } else { echo $rootMenu['TITLE']; } ?> </th> 


Anyone can help me?

Last edited by lordrt21 : December 13th, 2012 at 01:20 AM.

Reply With Quote
  #2  
Old December 13th, 2012, 02:12 AM
aeternus's Avatar
aeternus aeternus is offline
For POny!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: Amsterdam
Posts: 416 aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 4 h 56 m 43 sec
Reputation Power: 114
Your code could use some indentation. Apart from that you could use the modulus operator ].

Here an example run it and you see how it works:

PHP Code:
<?php

for($i=1;$i<20;$i++){
    
    if(
$i != 0){     // modulus   (if the remainder of $i/4 is not 0)
        
echo 'normal line '.$i.'<br />';   
    }else{
        echo 
'special line '.$i.'<br />';
        
// this applies to every fourth line 
    
}
    
}


?>
Comments on this post
lordrt21 agrees!
__________________
PHP Tutorial

Last edited by aeternus : December 13th, 2012 at 02:16 AM.

Reply With Quote
  #3  
Old December 14th, 2012, 12:21 AM
lordrt21's Avatar
lordrt21 lordrt21 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 212 lordrt21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 9 h 39 m 19 sec
Reputation Power: 4
thanks for the heads-up

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Add a line break automatically after a specific count for a table's elements

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap