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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:11:48+00:00 2026-05-26T01:11:48+00:00

I am trying to practice programming and I have decide to place some effect

  • 0

I am trying to practice programming and I have decide to place some effect on the login page. Since I am working on an online store I would want to display some random products somewhere in the login page that changes after every few seconds.

Now, I am stuck on how will I be able to extract a single product that will be displayed after an ajax call. I was thinking of getting the minimum and maximum product id on the database then randomly generate a number between the minimum and maximum product id then get the product with that ID but I thought that what if the ID that is randomly generated doesn’t match any product. It will just display nothing on the login page for seconds which I don’t want to happen.

Is there a way that I can have an ID that will surely be in the product table? Your help will be greatly appreciated. Thanks in advance.

PS:

I am using MySQL and PHP.

UPDATE:

I have came across a page stating that I can use:

SELECT * FROM `table` ORDER BY RAND() LIMIT 0,1;

Will this be a good solution for it?

  • 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-26T01:11:49+00:00Added an answer on May 26, 2026 at 1:11 am

    If you are using MSSql you can order by the newId() function to randomly get a row of data. You still need a service/page on the server side to run this code for you.

    select top 1 productName, sku
    from products
    order by newid()
    

    for MySql this would suffice

    SELECT productName, sku
    FROM products
    ORDER BY Rand()
    LIMIT 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to solve some queries from sql zoo to practice sql skills I have
Recently I was trying some practice programs in python and I came across this
I'm using Eclipse with C++ plugins on my macbook, trying some practice projects to
Hi I'm trying to get some practice with Linked Lists. I Defined an Object
I am trying to find a resource where I can practice my programming skills
I'm trying to get a better understanding of what place (if any) Macros have
I'm starting to learn and practice some CoreData, with no programming experience. After searching
I am trying to practice making making some xml and also a parser for
I'm trying to solve a programming problem to practice for a competition tomorrow, and
I am new to Javascript (and programming in general) and have been trying to

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.