Best possible way to loop thru static pages 
Author Message
 Best possible way to loop thru static pages

Hello guys,

I have following situation, i have database with 100 pictures of users,
every midnight i want to generate new static html page, name it 01.html
for example, and put picture of user with id 1, next midnight i want to
rename 01.html to 02.html and put next user from database on page 01.html
after all 100 users have been displayed i want to return to 1st user in
db, and loop this way for eternity, i know i can make a text file with id
of last shown user, and read it every time, my question is. How can make
sql query that will solve this problem? I know i specify offset, but when
i hit last users i have problem, at least as i think.

Sorry for this confusing post, hope someone would spare a minute to help.
Thank You very much in advance, and good luck to everyone on this lis



Sat, 24 Sep 2005 02:43:43 GMT  
 Best possible way to loop thru static pages
I am a big fan of not using databases.  I see no purpose for databases
except to slow youand your computer down.

I would put a directory with files

1.htm
2.htm
3.htm

and a directory one level higher for the pictures.

pictures/1.jpg
pictures/2.jpg
pictures/3.jpg

Load all htm in array, count them, Then at midnight copy  the
lastcount  xxx.htm to dummy.htm, rename all the other .htm and .jpgs
down one, then move dummy.htm to 1.htm.  Easy as pie!!!

Quote:

> Hello guys,

> I have following situation, i have database with 100 pictures of users,
> every midnight i want to generate new static html page, name it 01.html
> for example, and put picture of user with id 1, next midnight i want to
> rename 01.html to 02.html and put next user from database on page 01.html
> after all 100 users have been displayed i want to return to 1st user in
> db, and loop this way for eternity, i know i can make a text file with id
> of last shown user, and read it every time, my question is. How can make
> sql query that will solve this problem? I know i specify offset, but when
> i hit last users i have problem, at least as i think.

> Sorry for this confusing post, hope someone would spare a minute to help.
> Thank You very much in advance, and good luck to everyone on this lis



Sat, 24 Sep 2005 09:11:13 GMT  
 Best possible way to loop thru static pages
 > of last shown user, and read it every time, my question is. How can make
 > sql query that will solve this problem? I know i specify offset, but when
 > i hit last users i have problem, at least as i think.

Before looping, do a Select Count(*) From Users (filling in your names,
of course).  Compare this count to the "next" user.  If you're due for
user 101, and your count is 100, you know it's time to reset back to 1.

(this example's a little verbose, but it's the way I've been doing quite
a large app.  the fetch_object gives something that you don't have to
escape out of quotes to use it...)

...
$rstCount = mysql_query("Select Count(*) As High_Num From Users", $db);
$rowCount = mysql_fetch_object($rstCount);
$iHighNumber = $rowCount->High_Num;

$rstNext = mysql_query("Select Last_Nbr From Hold_Table", $db);
$rowNext = mysql_fetch_object($rstNext);
$iNextID = $rowNext->Last_Nbr;

if ($iNextID > $iHighNumber)
{   $iNextID = 1;

Quote:
}

else
{   $iNextID++;

Quote:
}

mysql_query("Delete From Hold_Table", $db);
mysql_query("Insert Into Hold_Table Values ($iNextID)", $db);
...

At this point, your creation logic would just use $iNextID, which will
be set properly.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~   /   \  /             Live from Montgomery, AL!   ~
~  /     \/       o                                  ~
~ /      /\   -   |       AIM:  LXi0007              ~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Sat, 24 Sep 2005 11:49:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. For loop, possible to increment counter/exit loop?

2. CPCS loop thru associated file question

3. looping thru a dimensioned field

4. looping thru an array, one day at a time

5. Newbie-Can I loop thru all class variables?

6. Web Page Listing Ways People Use Ruby

7. Best Place to trap all ways out of a window

8. Which ways better??

9. best ways to flush?

10. Better ways of expressing "KIND"

11. Good ways to debug Tcl/Tk?

12. A possible way to static initialization

 

 
Powered by phpBB® Forum Software