Page 1 of 1

MySQL output in two columns

Posted: Sat Sep 17, 2005 11:39 am
by NilsK
I have the following code:

Code: Select all

while ($i < $number):
	    $id = mysql_result($result,$i,"id");
	    $name = mysql_result($result,$i,"name");
	    $name = unescape_and_decode( $name );

            $uppercase_begin = strtoupper($name[0]);
            if ( $uppercase_begin != $at ) {
               $cat_list .= "<hr />\n";
               $cat_list .= "<a name=\"$uppercase_begin\">\n";
               $cat_list .= "<p class=\"index_header\">$uppercase_begin</p>\n";
               $cat_index .= " [ <a href=\"#$uppercase_begin\">$uppercase_begin</a> ] ";
            }
            $at = $uppercase_begin;

	    $cat_list .= "<a href=\"view_cat.php?id=$id&cat_name=".urlencode($name)."\">$name</a><p></p>";
	    $i++;
	    endwhile;
	    endif;

print $cat_index;
print $cat_list;
This code shows the categories in only one column. I want '$cat_list' to be displayed in two...
Any ideas?
The upper case letters should be as they are.

Posted: Sat Sep 17, 2005 12:52 pm
by feyd
how do you want to display them? horizontally tiled or vertically tiled?
viewtopic.php?t=25105 talks about horizontal tiling
viewtopic.php?t=37448 talks about vertical tiling (2 forms of)

Posted: Sat Sep 17, 2005 1:13 pm
by NilsK
feyd wrote:how do you want to display them? horizontally tiled or vertically tiled?
I want two columns horizontally for each row...
In HTML:
<tr><td>Cat 1</td><td>Cat 2</td></tr>
<tr><td>Cat 3</td><td>Cat 4</td></tr>

and so on...

Posted: Sat Sep 17, 2005 1:37 pm
by feyd
read the first link then ;)