farkewie Posted April 13, 2008 Share Posted April 13, 2008 Hi i am trying to display comtent in 2 columns but it keeps staying in 1 basiclyi want it to look like below item1 item2 item3 item4 item5 item6 Here is the piece of code im trying to edit. <?php if($config['content_top']) { $mService = new MenuService(); echo $GLOBALS['MENU']->getContent(); unset($meService); } // echo '<div id="preview">'; $ir = new ItemRequest($itemtype); $ir->setID($GLOBALS['MENU']->getID()); $ir->setLanguageID($GLOBALS['MENU']->getLanguageID()); $ir->setItemType(_BIGACE_ITEM_MENU); if($config['show_hidden']) { $ir->setFlagToExclude($ir->FLAG_ALL_EXCEPT_TRASH); } $ir->setOrderBy($params['orderby']); $ir->setOrder($params['order']); $menus = new SimpleItemTreeWalker($ir); $ct = $menus->count(); $half = ($ct / 2 ); $round = floor($half); $in = 0; print "<table>"; print $round; for ($i=0; $i < $menus->count(); $i++) { print "<tr>"; $temp_menu = $menus->next(); $url = LinkHelper::getUrlFromCMSLink( LinkHelper::getCMSLinkFromItem($temp_menu) ); // echo '<div class="nextLevelPreview">'; echo '<h3><a href="'.$url.'" title="'.$temp_menu->getName().'">'; echo $temp_menu->getName(); echo '</a></h3><p>'; if( strlen(trim($temp_menu->getDescription())) > 0 ) echo $temp_menu->getDescription(); else echo getTranslation('empty_description'); echo ' <a href="'.$url.'" title="'.getTranslation('list_link_title').$temp_menu->getName().'"><img border="0" src="'.$GLOBALS['_BIGACE']['DIR']['public'].'modul/images/3arrows.gif" alt="'.getTranslation('list_img_alt').'"></a>'; //echo '</p></div>'; print "</tr>"; $in++; if ($in == $round ) { print "<td></td>"; } } print "</table>"; // echo '</div>'; // display content below submenus?!? if($config['content_bottom']) { $mService = new MenuService(); echo $GLOBALS['MENU']->getContent(); unset($meService); } ?> Any help would be great. Link to comment https://forums.phpfreaks.com/topic/100961-trying-to-display-output-in-to-columns/ Share on other sites More sharing options...
ucffool Posted April 15, 2008 Share Posted April 15, 2008 Remember, for every: <tr></tr> it should have 2 <td></td>, one for each column. from glancing at your code, you have it only doing a single IF statement evaluated once for whether there should be a <td></td>. Link to comment https://forums.phpfreaks.com/topic/100961-trying-to-display-output-in-to-columns/#findComment-517397 Share on other sites More sharing options...
benphp Posted April 15, 2008 Share Posted April 15, 2008 I use modulus when doing this. Google it. Here's a site that talks about it: http://forums.seochat.com/seo-scripts-10/building-a-table-with-php-how-to-do-two-columns-187040.html Link to comment https://forums.phpfreaks.com/topic/100961-trying-to-display-output-in-to-columns/#findComment-517399 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.