Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Since you are going to make it integrated with threads I'd recommend using the threads way of doing templates.

Thus, you should first put the categories in an array, possibly with subcategories as an array in the array of main categories.

Then, in the template, you have a loop that goes through the array and outputs table cells for each main category. For each iteration of the loop you increment a variable by one, and if that number can be divided by the number of columns you want, you just print the </tr>.

Something like this:
Code
<br />$CatColumns = 3;<br />$Numberofcats = 15;<br /># This calculates the number of cells we need.<br />if ( $Numberofcats % $CatColumns != 0 ) {<br />   $cells = $Numberofcats + ( $CatColumns - ( $Numberofcats % $CatColumns ) );<br />} else {<br />   $cells = $Numberofcats;<br />}<br /><br />for ($i = 1; $i <= $cells; $i++) {<br />   # Check if this is the first cell of the row.<br />   if ( ($i - 1) % $CatColumns == 0 ) {<br />      print "<tr>\n";<br />   }<br />   # Make sure we have something to print.<br />   if ( $i <= $Numberofcats ) {<br />      print "<td> $i. {$catarray[$i]['name']} </td>\n";<br />   } else {<br />     print "<td> <!-- empty cell --> </td>\n";<br />   }<br />   # Check if this is the last cell of the row.<br />   if ( $i % $CatColumns == 0 ) {<br />      print "</tr>\n";<br />   }<br />}<br />

Sponsored Links
Entire Thread
Subject Posted By Posted
Links Directory project. Question about loops. fishtails 02/04/2003 12:45 AM
Re: Links Directory project. Question about loops Gardener 02/04/2003 2:15 AM
Re: Links Directory project. Question about loops fishtails 02/04/2003 11:32 PM
Re: Links Directory project. Question about loops Gardener 02/05/2003 1:31 AM
Re: Links Directory project. Question about loops AKD96 02/05/2003 3:57 AM
Re: Links Directory project. Question about loops AllenAyres 02/05/2003 4:16 AM
Re: Links Directory project. Question about loops JoshPet 02/05/2003 6:17 AM
Re: Links Directory project. Question about loops fishtails 02/05/2003 5:17 PM
Re: Links Directory project. Question about loops dimopoulos 02/05/2003 5:33 PM
Re: Links Directory project. Take a look - commen fishtails 02/11/2003 3:03 AM
Re: Links Directory project. Take a look - commen JustDave 02/11/2003 3:21 AM
Re: Links Directory project. Take a look - commen JoshPet 02/11/2003 3:30 AM
Re: Links Directory project. Take a look - commen smilesforu 02/11/2003 11:59 AM
Re: Links Directory project. Take a look - commen dimopoulos 02/11/2003 2:50 PM
Re: Links Directory project. Take a look - commen Gardener 02/11/2003 8:16 PM
Re: Links Directory project. Take a look - commen AllenAyres 02/12/2003 12:37 AM
Re: Links Directory project. Take a look - commen AllenAyres 02/12/2003 7:46 AM
Re: Links Directory project. Take a look - commen fishtails 02/12/2003 6:11 PM
Re: Links Directory project. Take a look - commen JustDave 02/12/2003 7:45 PM
Re: Links Directory project. Roadmap fishtails 02/13/2003 6:14 AM
Re: Links Directory project. Roadmap JoshPet 02/13/2003 6:21 AM
Re: Links Directory project. Roadmap JustDave 02/13/2003 7:42 AM
Re: Links Directory project. Roadmap Gardener 02/13/2003 12:40 PM
Re: Links Directory project. Roadmap dimopoulos 02/13/2003 3:50 PM
Re: Links Directory project. Roadmap AllenAyres 02/14/2003 6:21 AM
Re: Links Directory project. Roadmap fishtails 02/17/2003 12:46 AM
Re: Links Directory project. Roadmap JoshPet 02/17/2003 1:04 AM
Re: Links Directory project. Roadmap JustDave 02/17/2003 3:02 AM
Re: Links Directory project. Roadmap dimopoulos 02/17/2003 3:54 AM
Re: Links Directory project. Roadmap AllenAyres 02/17/2003 4:37 AM
Re: Links Directory project. Roadmap omegatron 02/17/2003 5:16 AM
Re: Links Directory project. Roadmap fishtails 02/17/2003 6:39 PM
Re: Links Directory project. Roadmap omegatron 02/17/2003 7:39 PM
Re: Links Directory project. Roadmap AllenAyres 02/18/2003 5:25 AM
Re: Links Directory project. Roadmap fishtails 02/19/2003 6:45 PM
Re: Links Directory project. Roadmap JoshPet 02/19/2003 6:56 PM
Re: Links Directory project. Roadmap dimopoulos 02/20/2003 12:55 AM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Posts: 70
Joined: January 2007
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240506)