MySQL output in two columns

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
NilsK
Forum Newbie
Posts: 3
Joined: Sat Aug 13, 2005 5:45 am
Location: Norway

MySQL output in two columns

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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)
NilsK
Forum Newbie
Posts: 3
Joined: Sat Aug 13, 2005 5:45 am
Location: Norway

Post 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...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

read the first link then ;)
Post Reply