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

  • Home
  • SEARCH
  • 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 3599814
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:24:53+00:00 2026-05-18T20:24:53+00:00

UPDATE : Thanks for all the quick responses. Should have probably clarified that I’ve

  • 0

UPDATE: Thanks for all the quick responses. Should have probably clarified that I’ve already got JQuery providing the widgets with functionality. But it is helpful to better understand what the relationship is btw HTML, Javascript and PHP in web development.

I am trying to put together a web page that queries a database and returns some pre-written MySQL queries:

I have a handful of queries like:

function someQuery($connection) {

 $query = "SELECT DISTINCT Column1, Column2
                 FROM TABLE1, TABLE2
                 WHERE TABLE1.Colum1_ID = TABLE2.Colum1_ID";

        if (!($result = @ mysql_query ($query, $connection)))
           showerror();

        if (@ mysql_num_rows($result) != 0) {
           echo "\n<table border=1 width=100%>";

           echo "\n<tr>" .
                 "\n\t<th>Column1</th>" .
                 "\n\t<th>Column2</th>" .
                 "\n</tr>";

           while($row = @ mysql_fetch_array($result)) {

              echo "\n<tr>" .
                    "\n\t<td>{$row["Column1"]}</td>" .
                    "\n\t<td>{$row["Column2"]}</td>";

           }
           echo "\n</table>";
        }

then I have widgets for displaying the functions:

   <li class="widget">  
       <div class="widget-top">
          <h3>Query Category</h3>
           <select>
             <option value="1">Query of Interest 1</option>
             <option value="2">Query of Interest 2</option>
             <option value="3">Query of Interest 3</option>
             <option value="4"Query of Interest 4</option>
           </select>
       </div>
       <div class="widget-content">
           <p><?

            ****Would Run Query here ****, but want to check the selections above and run query associated with selected option.

              ?></p>
       </div>
   </li>

So my question is, how do it set it up so that the user could select one of the queries of interest from the drop down menu so that the associated PHP function will run, displaying the query results the user selected??

I’ve done a lot of searching around and was suprised to find that nothing seems to match what I am trying to do here, although I feel like this is a rather routine feature.

  • 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-18T20:24:54+00:00Added an answer on May 18, 2026 at 8:24 pm

    The easiest way to do this, is to use the onChange event from the SELECT form element. When the event is fired, you could then call an AJAX function, to populate (by executing a server side script) the DIV tag.

    The below sample assumes the use of jQuery.

    Give your select element an ID

    <select id="myselect">
        <option value="1">query 1</option>
        <option value="2">query 2</option>
        <option value="3">query 3</option>
    </select>
    

    Then add a jquery script to populate the DIV tag.

    $('#myselect').change(function() {
        $('.widget-content').load('runquery.php?id='+this.options[this.selectedIndex].value);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE : Thanks for all the quick responses. Should have probably clarified that I've
UPDATE: Thanks to everyone for the responses. I didn't realize document.write() was deprecated. Add
Hey all, kind of new at Kohana and I have a quick question. I
I got a strange behavior with an Eclipse installation: Even though all update sites
Update : I have a couple of what are probably silly questions about commenter
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here:
Update: Solved, with code I got it working, see my answer below for the
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
I have read through the solutions to similar problems, but they all seem to
I'm tidying up some older code that uses 'magic numbers' all over the place

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.