> ... my problem is I want 3 images to appear in any one row in the table.
> Subsequent images I want to start in the next row down, subject to a limit
> of 3 and so forth.
Some naive and simplistic 'pseudo' code:
<code>
int current = 0, max = 3;
print_table_row_start();
while (sql_row = get_sql_rows())
{
if (++current > max)
{
print_table_row_end();
print_table_row_start();
current = 0;
}
print_table_entry(sql_row, current);
}
print_table_row_end();
</code>
Another approach could be:
<code>
create table images (
id int not null primary key auto_increment,
image <sometype>
);
select a.image as first, b.image as second, c.image as third
from images as a
left join images as b on (a.id = b.id+1)
left join images as c on (a.id = c.id+2);
</code>
In this case you should skip all rows but every third when outputting. That
could be mitigated with a group_id column of sorts in the images table
together with a group by expression.
(A sql guru can propably tell you how to do this without a group_id column)
--
Aigars
Bait: MySQL, SQL
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php