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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:31:01+00:00 2026-06-08T19:31:01+00:00

The website I am working on provides a service, where only members can get

  • 0

The website I am working on provides a service, where only members can get full access to the content. I am trying to create a ‘sample’ on the homepage that fetches NEW mysql data (that is normally available for members only) every day and provides ALL users with a ‘free sample’ of what the site has to offer.

The database contains over one thousand entries and I would like to find a way to fetch new mysql data from the db every day.

Assuming my database looks like this:

id    cars
1     honda
2     volvo
3     ford
4     audi

I would like the ‘car of the day’ to be ‘honda’ for 24 hours, then ‘ford’ for 24 hours, then ‘audi’ for 24 hours, etc…

this is what I have so far:

<?php 
    //Create mysql connect variable
    $conn = mysql_connect('server', 'username', 'password');
    //kill connection if error occurs
    if(!$conn){
        die('Error: Unable to connect. <br/>' . mysql_error());
    }
    //connect to mysql database
    mysql_select_db("masdswe9", $conn);

    $results = mysql_query("SELECT * FROM cars");

    $name_array = Array();

    while($row = mysql_fetch_array($results)){
        $name_array[] = $row['name'];
    }
    shuffle($name_array);

   /* I would like for this to fetch NEW SQL data every 24 hours, 
   since I am shuffling names above, slot 0 will be different once I 
   come up with a way to fetch new mysql data every 24 hours */
    echo $name_array[0];
?>
  • 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-06-08T19:31:03+00:00Added an answer on June 8, 2026 at 7:31 pm

    I would create a DB table called CarOfTheDay that you can select from (it will just have the ID of the car in the Cars table). Either that or you can have a column carOfTheDay, or change the order of the cars, but I think those are a bit more intrusive.

    Create a cron that runs once a day ans writes a random car to CarOfTheDay. Then, you can do what you are doing above, but you don’t have to worry about timing and you will only select one car:

    SELECT
       cars
    FROM
       CarOfTheDay
       JOIN Cars USING (id)
    LIMIT 1
    

    The LIMIT should not be necessary if you stick to one CarOfTheDay.

    By the way, use PDO or mysqli rather than mysql_*. Only select columns you need (don’t use SELECT * in production code) .. and only select rows you need (you can randomize in the query).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am collecting full HTML from a service that provides access to a very
We are working on a website which will provide the client access to a
I'm working on a website where a user can implement a C# code solution
I am working on an Intranet helpdesk website that provides a search on some
I am working on asp.net website with sql database which provides membership support. After
I'm working on an ASP.NET website in which I'll need to access an usb
I'm working on an internet website that provides some services to internet users. So
Is there any website which provides the service for testing SQLite code online? For
I have working website in PHP with a MySQL backend which has several tables
My website is working fine on IE, but when I open it on Firefox,

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.