Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6636903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:14:42+00:00 2026-05-25T23:14:42+00:00

I have 3 thumbnails which i want to rotate each time a user refresh

  • 0

I have 3 thumbnails which i want to rotate each time a user refresh the page. Therefore want to show different thumbnail each time. I have image name stored in the database. I am using this SQL query to fetch “select thumbnail from tablename order by rand() limit 1”. It is fetching one thumbnail perfectly.

The problem is that sometime same images comes up. For example first time i refresh the page thumbnail 1.jpg shows but second time again 1.jpg comes up.

So what i am looking for is to have different thumbnail each time i refresh the page.

Can anyone provide me some suggestions to achieve this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:14:43+00:00Added an answer on May 25, 2026 at 11:14 pm

    this is not possible with random selection, as the same image can come again.

    For the effect you want you need to use a cookie to store the last displayed image name and NOT display that image for the next request.

    As you have confirmed in your comment you do not want to display the last displayed thumbnail. IN that case you can do this like this using sessions:

    // get last shown from session if any
    $last_shown = '';
    if(isset($_SESSION['last_shown_thumb']))
        $last_shown = $_SESSION['last_shown_thumb'];
    
    // select a thumbnail randomly which is not the one last shown
    $query = "SELECT thumbnail FROM tablename WHERE thumbnail <> '" . $last_shown . "' order by rand() limit 1";
    $res = mysql_query($query);
    $row = mysql_fetch_row($res);
    $curr_thumb = $row[0];
    
    // set the current to last shown in session
    $_SESSION['last_shown_thumb'] = $curr_thumb;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one video object and 3 thumbnails which, when clicked, will play different
I have an image uploader and cropper which creates thumbnails and I occasionally get
I have this script at the moment, which changes an image when a thumbnail
I have a list of thumbnails. When I click on a thumbnail, I want
I've read about creating a HttpHandler to call each time I want to show
I'm making an image gallery and I want to have a bunch of thumbnails
I want to store the thumbnail image for video after the user start recording,
I have a bunch of thumbnails which I am loading with a style of
I have a string which follows literally : lt;img src=quot;http://www.news.gov.tt/thumbnail.php?file=Hon__Jerry_Narace_Minister__Of_Health_599152837.jpgamp;size=summary_mediumquot;gt;lt;pgt;Fifty-eight people have been tested
I have thumbnails on a page, as such: <div id=credits> <a href=largeimage1.jpg alt=credits1.php><img src=thumb1></a>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.