Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 08:22 am EST
Geeklog Forums
PHP Blocks and 4images
Status: offline
rav
Forum User
Chatty
Registered: 01/14/03
Posts: 37
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.
16
14
Quote
Status: offline
nurseryboy
Forum User
Chatty
Registered: 09/04/02
Posts: 43
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. 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
12
22
Quote
Status: offline
nurseryboy
Forum User
Chatty
Registered: 09/04/02
Posts: 43
No problem
14
17
Quote
Status: offline
rav
Forum User
Chatty
Registered: 01/14/03
Posts: 37
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
17
20
Quote
Status: offline
nurseryboy
Forum User
Chatty
Registered: 09/04/02
Posts: 43
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!
12
13
Quote
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....
10
15
Quote
All times are EST. The time is now 08:22 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content