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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:29:19+00:00 2026-06-03T18:29:19+00:00

I have a working mysql query that retrieves data from table1. Now I will

  • 0

I have a working mysql query that retrieves data from table1.

Now I will add every month a new table (table2, table3..etc).

Goal 1 : I would like to add a drop down menu and populate it with all tables as user options.

Goal 2 : I would like to make the query connect to the table that the user selects from the drop down menu, retrieves data and then refresh the page or just the table’s div to display updated data.

my current mysql/php code :

$query = "SELECT X, Y, Z FROM **table1**";

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)) 

{
echo $row['X'];

echo $row['Y'];

echo $row['Z'];
}

Instead of “table1” it should be a variable linked to the drop down menu that the user selects.

I feel it should be simple, but I am bit new to this and could not find a similar case.

Thanks a lot gents.

  • 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-03T18:29:20+00:00Added an answer on June 3, 2026 at 6:29 pm

    I like the comment above but here is an example not sure if that what you are looking for

    <form action="process.php" method='post'>
            <select name="tables">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            </select>
            <input type="submit" />
            </form>
    

    process.php file

     $table=$_POST['tables'];
    $query = "SELECT X, Y, Z FROM  ".$table;
    
    $result = mysql_query($query) or die(mysql_error());
    
    while($row = mysql_fetch_array($result)) 
    
    {
    echo $row['X'];
    
    echo $row['Y'];
    
    echo $row['Z'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a mysql query that will search a database of entries
I have a java program that connects to a MySql database and it's working
I am currently working on a MySQL query that contains a table: TBL:lesson_fee -fee_type_id
I'm working on a mysql query in a Drupal database that pulls together users
I have a PHP document that query's a MYSQL database based on the input
I'm working on a small Ruby program that will connect to a remote MySQL
I'm working with a MySQL query that writes into an outfile. I run this
I have a MySQL database that I'm working with, but when I try to
I have been working on a script that pulls testimonials from a database, adds
I have a working mysql query which returns all of the people NOT registered

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.