Jump to content

How can I make the categories display in list style instead of left to right.


Cynical

Recommended Posts

I have this piece of code but I'm unsure of how to make it sort in list style instead of left to right.. 
 
Example 1, How it is now: 
 
Category1 - SubCategory1 | Category1 - SubCategory2 | Row 3 | Row 4 | Row 5 |
 
Category1 - SubCategory3 | Category2 - SubCategory1 | Row 3 | Row 4 | Row 5
 
Example 2, What I need it to do:
 
Category1 - SubCategory1 | Category2  - SubCategory2    
 
Category1 - SubCategory2 
 
Category2  - SubCategory1 
 
Column 4
 
Column 5
 

If anybody could guide me to some examples/tutorials or has any pointers it would be much appreciated.

 

I tried looking at some SQL examples but all they showed me is what I've already done.

<table align="center">
<tr align='right'>
<?php
$i = 0;
$cats = SQL_Query_exec("SELECT * FROM categories ORDER BY parent_cat, name");
while ($cat = mysql_fetch_assoc($cats)) {
    $catsperrow = 5;
    print(($i && $i % $catsperrow == 0) ? "</tr><tr align='right'>" : "");
    print("<td style=\"padding-bottom: 2px;padding-left: 2px\"><a href='categories.php?cat={$cat["id"]}'>".htmlspecialchars($cat["parent_cat"])." - " . htmlspecialchars($cat["name"]) . "</a> <input name='c{$cat["id"]}' type=\"checkbox\" " . (in_array($cat["id"], $wherecatina) || $_GET["cat"] == $cat["id"] ? "checked='checked' " : "") . "value='1' /></td>\n");
    $i++;
}

Thanks in advance for any help. 

Edited by Cynical
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.