Problem with layout mySQL query

This is a discussion on Problem with layout mySQL query within the PHP Language forums, part of the PHP Programming Forums category; hi there, A few days ago i posted a question how i could divide a query's result over 2 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-16-2004
knoak
 
Posts: n/a
Default Problem with layout mySQL query

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:

> 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>';


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
Reply With Quote
  #2 (permalink)  
Old 12-16-2004
Pedro Graca
 
Posts: n/a
Default Re: Problem with layout mySQL query

knoak wrote:
> 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:
>
>> 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;


}

I'm sorry if I didn't put that in the first time around -- but you
should have corrected it :-)

>>
>> if ($column) echo '<td>(empty cell)</td></tr>';
>> echo '</table>';

>
> 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.


To me, the code above shows the layout on the right.

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


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!
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:20 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0