Connecting Tech Pros Worldwide Help | Site Map

Problem with layout mySQL query

knoak
Guest
 
Posts: n/a
#1: Jul 17 '05
hi there,

A few days ago i posted a question how i could divide a
query's result over 2 collumns.

I got the following code thanks to Pedro:
[color=blue]
> echo '<table class="search_result" summary="search result">';
> $column = 0;
> while ($row = mysql_fetch_array($result)) {
> if (!$column) echo '<tr>';
> echo '<td>', $row['whatever'], '</td>';
> if ($column) echo '</tr>';
> $column = !$column;
>
> if ($column) echo '<td>(empty cell)</td></tr>';
> echo '</table>';[/color]

It works great except for one thing:
When the result is for example 5 items,

The table looks like: Instead of:
_____ _____ _____ _____
|__x__|__x__| |__x__|__x__|
|__x__|__x__| |__x__|__x__|
|__x__| |__x__|_____|

"x" indicates an item.

Anyway, can someone please help me to get the table
structure correct? Any help would be great.

Greetings knoak
Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Problem with layout mySQL query


knoak wrote:[color=blue]
> A few days ago i posted a question how i could divide a
> query's result over 2 collumns.
>
> I got the following code thanks to Pedro:
>[color=green]
>> echo '<table class="search_result" summary="search result">';
>> $column = 0;
>> while ($row = mysql_fetch_array($result)) {
>> if (!$column) echo '<tr>';
>> echo '<td>', $row['whatever'], '</td>';
>> if ($column) echo '</tr>';
>> $column = !$column;[/color][/color]

}

I'm sorry if I didn't put that in the first time around -- but you
should have corrected it :-)
[color=blue][color=green]
>>
>> if ($column) echo '<td>(empty cell)</td></tr>';
>> echo '</table>';[/color]
>
> It works great except for one thing:
> When the result is for example 5 items,
>
> The table looks like: Instead of:
> _____ _____ _____ _____
>|__x__|__x__| |__x__|__x__|
>|__x__|__x__| |__x__|__x__|
>|__x__| |__x__|_____|
>
> "x" indicates an item.[/color]

To me, the code above shows the layout on the right.
[color=blue]
> Anyway, can someone please help me to get the table
> structure correct? Any help would be great.[/color]

Post your code (or a stripped-down version of it) instead of the code
you used as a basis.

In my code, the first line after the while() loop is responsible for
filling the empty cell. Maybe you edited it out when you adapted the
code to suit your needs.

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Closed Thread