|
Posted by nemo on 06/05/05 11:40
On Fri, 03 Jun 2005 07:09:27 GMT, nemo <no_address@not_hotmail.com> wrote:
> >It sounds good.
> >So, if I understand it properly, I could do it in following steps.
> >1) Put the photos in a table in mysql: one column can be made of photos and
> >another one of text describing each photo
>Don't put images themselves into the database, just the filenames, although
>I suppose you could include the path if that is likely to change with each
>image but will remain constant for that particular image. Otherwise just
>stick the path in the display code.
> >2) querying the photos from the database and resizing them by using php code
> >which I would insert at
> >https://www.scaiecat-spa-gigi.com/index.php
>About selecting which ones, I think my best shot would be for the table to
>have an auto-increment id_number, then for the $Query to be
>SELECT id_number, image_filename from table order by id_number limit N,2;
>where N is one more than the lower id_number from the previous SELECT. For
>this, I guess you'd have to put each new value for N in a file and refer to
>it with every Query. Also, I guess you'd have to find the max id_number and
>if it appears as N, set N to 0 and start over.
>Strictly kludge-ville. Someone might be able to provide a tidier, more
>elegant, solution.
On Fri, 03 Jun 2005 07:09:27 GMT, nemo <no_address@not_hotmail.com> wrote:
> >It sounds good.
> >So, if I understand it properly, I could do it in following steps.
> >1) Put the photos in a table in mysql: one column can be made of photos and
> >another one of text describing each photo
>Don't put images themselves into the database, just the filenames, although
>I suppose you could include the path if that is likely to change with each
>image but will remain constant for that particular image. Otherwise just
>stick the path in the display code.
> >2) querying the photos from the database and resizing them by using php code
> >which I would insert at
> >https://www.scaiecat-spa-gigi.com/index.php
>About selecting which ones, I think my best shot would be for the table to
>have an auto-increment id_number, then for the $Query to be
>SELECT id_number, image_filename from table order by id_number limit N,2;
>where N is one more than the lower id_number from the previous SELECT. For
>this, I guess you'd have to put each new value for N in a file and refer to
>it with every Query. Also, I guess you'd have to find the max id_number and
>if it appears as N, set N to 0 and start over.
>Strictly kludge-ville. Someone might be able to provide a tidier, more
>elegant, solution.
Forget all that - I wasn't thinking very clearly; there's no need for php to
open and close a file. Do it all automatically.
Add an auto-increment field to your table, caling it, say, id_number.
Now add another field to your table, calling it, say, Visible, and make its
default "Y". (That way, you don't need to do anything when adding
pictures.)
When calling your pictures, go something like this -
// check that there is a minimum of 2 pictures to display. If
// there isn't, that means you've exhausted the list, so
// change the Visibility mask back to "Y" globally.
$Query="select * from piccy_table where visibility=\"Y\" ";
$Result=mysql_db_query ($DBName, $Query, $Link);
while ($Row=mysql_fetch_array ($Result))
{
if (mysql_affected_rows <2)
update piccy_table set visibility=\"Y\";
}
// now you have at least 2 pictures to display
$Query="select * from piccy_table where visibility=\"Y\" order by id_number
desc limit 2";
$Result=mysql_db_query ($DBName, $Query, $Link);
while ($Row=mysql_fetch_array ($Result))
{
$images[]=$Row[image_filename];
}
// now set the visibility for the two displayed pictures to "N"
$Query="select * from piccy_table where visibility=\"Y\" order by id_number
desc limit 2";
$Result=mysql_db_query ($DBName, $Query, $Link);
while ($Row=mysql_fetch_array ($Result))
{
update piccy_table set visibility=\"N\";
}
$image1=$images[0];
$image2=$images[1];
Then stick $image1 and $image2 in your code to place them where you want
them on the page.
I haven't tested it, but it *should* work. Corrections welcome.
Navigation:
[Reply to this message]
|