Posted on: 02/19/03 11:52pm
By: rav
The geeklog & 4images integration worked perfectly, and I've been running it on my site since the day it was posted. I was wondering if anyone had any plans to do a "random photo block" for the 4images gallery. I've been poking around myself, but frankly, I'm still new to GL & PHP, and while eventually, I might be able to figure it out, I'm sure it would not be as good compared to most blocks/plugin's I've seen.
PHP Blocks and 4images
Posted on: 02/20/03 08:31am
By: nurseryboy
Hello,
Yes, I have created a random image block for 4images. I have been using it on my site for a while, and it seems to be working just fine. You can download the code
here[*1] . Just unzip, copy the code from the file into lib-custom, and create a block in GL that calls the new function.
That should be it
PHP Blocks and 4images
Posted on: 02/20/03 12:52pm
By: rav
OMG, so awesome!
Thanks!!!
PHP Blocks and 4images
Posted on: 02/20/03 07:23pm
By: nurseryboy
No problem
PHP Blocks and 4images
Posted on: 02/20/03 09:50pm
By: rav
That worked perfectly. Thank you very much!
After playing around with it for a few hours, I noticed that it didn't seem all that random (same photo kept coming back up, more often than not. I only have about 34 images currently, but the same image would load 9 out of 10 times.
I took a lil peek at your code, and read up on the rand() mysql fuction in an attempt to understand what you were doing.
I cam accross this:
<b>As of MySQL 3.23.52, MySQL changed the way
RAND() functions, such that you MUST supply a
SEED to get an actual random number. If you do
not, each new connection will return close to the
same number as the previous new connection. An
example to test this would be to run the follow
command multiple times in a row. mysql -u
username -p -e'select rand()' A basic way to seed
this would be to run RAND(NOW()).</b>
So I added the NOW() function to the RAND() and it totaly cured it for me. It seems much more random now, and I'm seeing images that were not showing up before.
Once again, thanks for the block, I know I couldn't have done it, but maybe this lil tweak will help others
PHP Blocks and 4images
Posted on: 02/21/03 08:54am
By: nurseryboy
Ok, cool. Thanks for finding that out. I will add it to the code right away.
I'm glad it is working fine for you too.
Have a great day!
PHP Blocks and 4images
Posted on: 03/10/03 07:00pm
By: Anonymous (Anonymous)
I like this block....
The RAND(NOW()) function did not work for me.
I kept getting the same image every time.
I found this in a post on mysql.com:
MD5(RAND())
This worked every time for me.
Hope this helps....