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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:36:25+00:00 2026-05-26T12:36:25+00:00

I currently am using mysql and php to display 9 random results from my

  • 0

I currently am using mysql and php to display 9 random results from my table of about 1100 records.

Would it be possible to have a next and previous button even though it’s random? I looked at a couple of the examples already posted here but they seem to be application/project specific. Here is what my code looks like..

    function executeQuery($searchKey)
    {

        if ($searchKey == null)
        {
    $query = "SELECT DISTINCT flightNumber, flightCity FROM allFlights LIMIT 0,9";
        //DEBUG -echo "<p>$searchKey</p>";echo "<p>$query</p>";
        }
        else
        {
        //DEBUG -echo "<p>$searchKey</p>";echo "<p>var not null</p>";
           $query = "Select distinct * from allFlights where flightCity LIKE '%$searchKey%' LIMIT 0,9";
        //DEBUG -echo "<p>$searchKey</p>";echo "<p>$query</p>";
        }
   $result=mysql_query($query);
   $numrow=mysql_numrows($result);
   if ($numrow === 0)
   {
    $query = "Select distinct * from allFlights where flightNumber LIKE '%$searchKey%' LIMIT 0,9";
    $result=mysql_query($query);
    $numrow=mysql_numrows($result);
   }
return $result;
     }

       function populate ()
       {
         $searchKey = mysql_real_escape_string($_POST["search"]); //assigns user input to searchKey variable
         //DEBUG -echo "<p>$searchKey</p>";
         $result=executeQuery($searchKey);
         $numrow=mysql_numrows($result);

     if ($numrow == 0)
     {
        echo "<center><p><b> No results found, please try another keyword.</p></center></b>";
     }
     else
     { display results. -- this part i have working.
             }

I prefer upon loading the page this happens:
-The current position with respect to the # of flights available are listed. (Now showing 9 of 1100 flights)
-9 random flights are displayed.
-Next button that will show the next 9 flights (random would be nice.)
-Previous button that will show the previous(original) 9 flights (random would be nice.)

When all is said and done I would like to be able to load the page identify the 9 random flights, press next identify the new 9 random flights, then previous and identify the original 9 random flights.

Any help is much appreciated.

  • 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-26T12:36:25+00:00Added an answer on May 26, 2026 at 12:36 pm

    You can use ORDER BY RAND(seed) to give a pseudorandom order that is repeatable:

    SELECT * 
    FROM ....
    ORDER BY RAND(9325)
    LIMIT 99, 9
    

    Adjust the offset to move back and forwards through the results. The seed can be any integer, and you can change it if you want to re-randomize the order, but you must use the same seed when pressing back or forward.

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

Sidebar

Related Questions

I get a random row from a mysql-server using php. I then display some
I have a php page displaying query results from mysql. This result is displayed
I have a php classifieds website (mostly) and I am currently using MYSQL as
I am currently using PHP/MySQL and the jQuery timeago plugin. Basically, I need to
I'm currently using PHP, JAVASCRIPT, MYSQL, XHTML, CSS to develop my site. Note that
I'm currently developing a website which stores bookmarks in a MySQL database using PHP
Greetings, I have some mysql tables that are currently using an md5 hash as
Currently, I am using an with ajax to update my mysql. Now, I have
My website currently divides and displays messages in a conversation using PHP. I would
Simply said: How do I receive data from a PHP echo to display using

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.