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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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! |