Re: Propagating a Table

2001-04-15 Thread Aigars Grins

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



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();



Another approach could be:



create table images (
id int not null primary key auto_increment,
image 
);

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



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




Propagating a Table

2001-04-15 Thread Steve Lowe

Hi,

I have MySQL 3.23.xx and PHP4

I am using a code to return images that puts them in a table.

The search works fine. It selects an image and returns it fine.

However, when more that one image is returned:.

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

All I can manage to return is 1 row of x images or 1 column of x images.

Can any one advise me on the correct approach?

Thanks,
Kindest Regards,

Steve Lowe


-
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