Jump to content

Random Image


radons

Recommended Posts

Hi, i was hoping someone could help me out...

I want to make a random image displayer that displays an random image.. That's not the problem though, the problem is that i want to give all the images have a pick chance. It will only show one image and must always show one.

So, one image has a pick chance of 40%, the other of 70% and so on.

I have no idea how to do this, thanks for your help =)
Link to comment
Share on other sites

i think u ment 40% and 60% otherwiseit would be over 100% but heres a lil sumet that will work

[code]
<?php
$images=file('randimages.txt');
$count=count($images);
$random=rand(0,$count);
echo $images[$random];
?>
[/code]
and then in the file randimages.txt put 6 of the image you want at 60% and 4 of the image name that you want to be 40% seporate by line..
like this:

image60.jpg
image40.jpg
image60.jpg
image60.jpg
image40.jpg
image40.jpg
image60.jpg
image40.jpg
image60.jpg
image60.jpg

and then use $images[$random] to display the image name inside the image tags..
Link to comment
Share on other sites

Thanks for the reply.

But an example of what i have now:

All images are stored in the database,

ID LINK CHANCE
1 image1.jpg 40%
2 image2.jpg 50%
3 image3.jpg 10%

I want it to pick one and the ones with a higher chance well get picked faster.


Also, i'm working on another system that shows random images. Which all have their own chance to be showed, but it is random if it will show up or not.

ID LINK CHANCE (to be shown)
1 image1.jpg 40%
2 image2.jpg 50%
3 image3.jpg 60%
4 image4.jpg 70%
5 image5.jpg 30%

Think about an RPG with an item drop system, something like that here.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.