well my goal here is to make a signature that randomly puts in a bunch of images but each image can only be used once. how would i do this(make the image only be choosen once)?
[PHP] use something once?
Started by high6, Jul 17 2006 11:57 AM
4 replies to this topic
#1
Posted 17 July 2006 - 11:57 AM
#2
Posted 17 July 2006 - 02:20 PM
Although I think your trying to use GD I don't know if it's still the same as I have never used it but you should look into the array_rand function and store the images in an array. If you don't know what an array is then it's like this.
Also to display them for example echo them you would use the array numbers for example $images[0] would be the string image..
I may not be right as I don't use GD. Infact I would bet i'm wrong after slowly looking into bits of GD functions I see it's a bit different..
<?php
$images array("image","image2","image3");
?>
Also to display them for example echo them you would use the array numbers for example $images[0] would be the string image..
I may not be right as I don't use GD. Infact I would bet i'm wrong after slowly looking into bits of GD functions I see it's a bit different..
Edited by Net-Margin, 17 July 2006 - 02:23 PM.
#3
Posted 17 July 2006 - 05:38 PM
What about placing all the images in a database, and then extract one at at time? Then, you can set a field in the database to 0 if it's not viewed yet, and to 1 if it's viewed, and extract only the images with value 0.
Another way of doing it could be to give all the images in the database an id, and start with #1 and then add +1 to the ID for each time the page is refreshed.
Just a few ideas, I hope I described well.
Another way of doing it could be to give all the images in the database an id, and start with #1 and then add +1 to the ID for each time the page is refreshed.
Just a few ideas, I hope I described well.
#4
Posted 17 July 2006 - 11:30 PM
I would recommend using Sessions so all images can be seen by everyone but not repeated for the same person. But if you want it to be global, then you need to use a database or a file to keep track of displayed images. (better use a file, just think of all the queries...)
#5
Posted 18 July 2006 - 03:27 PM
I'd load the images into an array, suffle() them, then just use a foreach or for loop to add how ever many of them you want to the "bigger" image.
You could also load the paths to them into a database, and then just select them with the rand() function of mySQL (same concept as an affiliate randomiser), and then loop through the results just as though you used shuffle().
That way, you don't have to do anything complex, and each image will only get used once.
Now, if you mean use each image once period (as in if you refresh the page, it will never show again), then just delete the entry from your database, or delete it from your server (depending on which method you used).
You could also load the paths to them into a database, and then just select them with the rand() function of mySQL (same concept as an affiliate randomiser), and then loop through the results just as though you used shuffle().
That way, you don't have to do anything complex, and each image will only get used once.
Now, if you mean use each image once period (as in if you refresh the page, it will never show again), then just delete the entry from your database, or delete it from your server (depending on which method you used).
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
