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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:58:20+00:00 2026-06-15T17:58:20+00:00

I currently have a drop-down menu box that takes an element from a column

  • 0

I currently have a drop-down menu box that takes an element from a column from my mySQL database and displays it in the drop-down box. The user can also select from five of the pre-determined options. When submit is clicked, the changes get reflected in the database.

There is no issue with my code, but I would like to make it more intuitive for the user. At the moment, upon clicking submit, the page refreshes, and the page loses its scroll position (once refreshed, the page goes to the top).

How would one make a submit button outside of the while-loop? I want to have the submit button at the bottom of the page, which would mean it will be outside of the iterating while loop, right? How could I do this?

Attached is my code:

<?
if (isset($_POST['formSubmit'])){
    $rating = $_POST['rating'];
    $accountID = $_POST['accountID']; 

mysql_query("UPDATE Spreadsheet SET rating='$rating' WHERE accountID='$accountID'");
}

while ($row = mysql_fetch_array($query)){ ?>

<form name ="rating" method ="POST" action ="" > <?

echo "<input type = 'hidden' name = 'accountID' value = '" . $row['accountID'] . "' >";

?>
    <select name="rating">

        <? $values = array('0 - No rating','1 - Very Bad','2 - Bad','3 - Average','4 - Above Average');

        for ($i =0; $i < count($values); $i = $i + 1){
            echo "<option value = \"$i\""; 

            if ($row['rating'] == $i) {
                echo "selected=\"selected\"";
            }

            echo ">" . $values[$i] . "</option>";

        }

        ?>

        </select>
        <input type ="Submit" name ="formSubmit" value ="Submit" />
        </form>
}
  • 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-15T17:58:22+00:00Added an answer on June 15, 2026 at 5:58 pm

    I suggest you work this out with AJAX. Instead of submitting it as form, send it as a AJAX request. Something like:

    $('select[name="rating"]').change(function () {
        var rating = $("select[name="rating"] option:selected").val();
        $.post(
            'YOUR-URL.php',
            {'rating' : rating},
            function(response) {
                //do what you got to do
            }
        )
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently have a drop down menu that is activated on a hover (from display:none
I have an expandable vertical drop down menu that currently expands when first level
I have a table that includes a column for the user to select from
I have a select field (drop-down menu) in a table column: <tr> <td> <select
I have a link that functions similar to a drop down menu in that
I have a drop down menu that has fading background images done by haveing
Currently I have a drop down box with all the options. After submit is
I currently have a CSS <ul><li> dropdown menu that uses the following code. Unfortunately
I have a css drop down menu working except for one thing: the last
I have got a drop down menu which works fine but i want 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.