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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:44:42+00:00 2026-06-15T18:44:42+00:00

I’m working on a bit of PHP/MySQL code that randomly outputs data selected from

  • 0

I’m working on a bit of PHP/MySQL code that randomly outputs data selected from the database.

For example, my database table contains values for Months, Days, and Events.

I run this query:

SELECT event_id, month, day_num, event FROM mytable WHERE month = DATE_FORMAT(CURDATE(), '%M') AND day_num = DAY(CURDATE());

The query returns several results:

event_id: 1388
Month: ‘December’
Day: 12
Event: ‘Nothing major happened.’

event_id: 1389
Month: ‘December’
Day: 12
Event: ‘This was an uneventful day.’

event_id: 1390
Month: ‘December’
Day: 12
Event: ‘Peaceful and quiet’

event_id: 1391
Month: ‘December’
Day: 12
Event: ‘Same old.’

I want to output one of the results into a browser, and then click a button and output another result. I want to make sure that every time a button is clicked, the output in the browser is not the same as immediately before.

For example, if the event_id that is currently output is 1388, I want to make sure that when I click the button, the event_id 1388 doesn’t get loaded.

Would be grateful for a bit of expertly advice.

  • 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-15T18:44:43+00:00Added an answer on June 15, 2026 at 6:44 pm

    If you need it sequentially you can use the limit as

    SELECT 
    event_id, 
    `month`, 
    day_num, 
    event 
    FROM mytable 
    WHERE month = DATE_FORMAT(CURDATE(), '%M') AND day_num = DAY(CURDATE()) 
    
    limit from,1;
    

    Here from is 1 for click, 2 for the second, 3 for the third and so on.

    You will have this query execution in a method which will receive the from as a parameter.
    At your front end, when the page loads initialize a variable to 0.
    As per your question, when a user clicks on the button,
    Set an onclick event on the button which will increment the variable by 1,
    Pass this variable to the method from where you are querying the database.
    So for every click you will get a new record.

    The from, 1 signifies that we need a single row from the rownumber.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a view passing on information from a database: def serve_article(request, id): served_article
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.