Random Image

Discussion in 'PHP' started by MajHate, Nov 26, 2008.

  1. #1
    Hello,

    I am working on a script where random images show up and people rate them. I am having one problem though. That is that the same images keep showing up! Does anyone know how to go about this? I was thinking maybe recording there IP address or something. Help!

    Thanks,
    Jason
     
    MajHate, Nov 26, 2008 IP
  2. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Just save a cookie :)
    setcookie()
     
    elias_sorensen, Nov 26, 2008 IP
  3. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What's the code you are using right now?

    You'll need to use something like RAND to select the image to display randomly.
     
    Christian Little, Nov 27, 2008 IP
  4. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #4
    As he wrote, he has already done that. He needs a tip on how to stop showing the same images :)
     
    elias_sorensen, Nov 27, 2008 IP
  5. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #5
    in your query

    select rand(idofpicture) ** rest of condition **;

    thats it
     
    bartolay13, Nov 27, 2008 IP
  6. justinlorder

    justinlorder Peon

    Messages:
    4,160
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I have a random php script that display images randomly when you refresh page.
    It doesn't have rate function nor record IP .
     
    justinlorder, Nov 27, 2008 IP
  7. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #7
    With that query, it will still be possible to find the same image multiple times!
     
    elias_sorensen, Nov 27, 2008 IP
  8. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #8
    try this tutorial. Should be pretty simple and easy to adapt to your need
     
    ads2help, Nov 28, 2008 IP
  9. misbah

    misbah Active Member

    Messages:
    265
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    68
    #9
    I agree with elias_sorensen
    you need cookie... so if image already choose it will save on user cookie
    after that array your image (before random your image) and unset your array with cookie
    and finally you can random your image array
     
    misbah, Nov 28, 2008 IP
  10. parkerproject

    parkerproject Active Member

    Messages:
    114
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    98
    #10
    can you post your random image code,because there are some tricks you can do to avoid same image showing twice in a row
     
    parkerproject, Nov 28, 2008 IP