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 7018035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:59:28+00:00 2026-05-27T22:59:28+00:00

Each time user enter’s website get random information/text from mysql. Question: How to make

  • 0

Each time user enter’s website get random information/text from mysql.
Question: How to make sure every time user refresh page she/he get difirrent information no the same viewed before?

First idea camed to my mind:

  1. User enter’s website, he/she get information which has $id= '123';
  2. That id we store in session
  3. User again refresh page and new if statment executed:
if ($id == $random_id_from_mysql) {
    //select new id from mysql, because it's the same, viewed before
} else {
    //show new information and store $id in session for feature usage
}

Any new method available for 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-27T22:59:29+00:00Added an answer on May 27, 2026 at 10:59 pm
    session_start();
    
    // If a value already exists in $_SESSION, it will be used.
    // Otherwise, NULL
    $prev_rand = isset($_SESSION['prev_rand']) ? $_SESSION['prev_rand'] : NULL;
    
    // Query for a random record that isn't equal to the previous one 
    // (or isn't NULL if no previous one exists)
    // using RAND() and LIMIT 1
    $result = mysql_query("SELECT id, col1 FROM tbl WHERE id <> '$prev_rand' ORDER BY RAND() LIMIT 1");
    $row = mysql_fetch_array($result);
    
    // Store the new rand value into session
    $_SESSION['prev_rand'] = $row['id'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am creating a listbox containing 2 text boxes each time a user
My Rails application makes use of Time.zone so that each user can set their
My question about My SQL is, I have a table where users enter time
I don't want users to have to enter their passwords each time, and I
I have a few textboxes. I'd like to point the user each time to
Each time a python file is imported that contains a large quantity of static
Each time my webpage is loaded it runs a routine in the page_load event
Each time I click on the map a new marker is placed on the
I want to output the function name each time it is called, I can
How do I run a batch file each time windows boots up also I

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.