By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

Problem with layout mySQL query

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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!
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.