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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:10:12+00:00 2026-06-15T13:10:12+00:00

Thanking you for taking the time to look at this question. The premise of

  • 0

Thanking you for taking the time to look at this question.

The premise of the situation is that I have a “website” written in PHP and HTML that displays items from my database named “Spreadsheet.” There are six columns, and over 4000+ rows of data. The columns are “accountID”, “accountName”, “website”, “rating”, “imageURL”, “comments.” The column “rating” in the website is a drop down list.

Currently, everything works well, but I have do questions:

  1. How do I, with PHP, have data submitted to the database upon clicking on an option (such as “Very Bad”) in the drop down list? At the moment, it requires the user to click a “submit” button, which refreshes the page entirely, losing their position. Is it possible to have it submit silently (without refreshing)
  2. Second question has to do with the drop-down list again. How do you have the drop-down list display what’s in the database? For example, if rating is “Very Bad” in the database, the drop-down list reflects that, and not what the first element is.

Below is my code.

    <a href =\"". $urlHTTP, $row['website']."\">". $row['website']."</a><br />
  <Form Name =\"rating\" Method =\"POST\" ACTION =\"\" />

  <input type = \"hidden\" name=accountID value=" . $row['accountID'] . ">
    <select name=\"rating\">
    <option value=\"\"></option>
    <option value=\"Very Bad\">Very Bad</option>
    <option value=\"Bad\">Bad</option>
    <option value=\"Average\">Average</option>
    <option value=\"Above Average\">Above Average</option>
  </select>

      <INPUT TYPE =\"Submit\" Name =\"formSubmit\" VALUE =\"Submit\">


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


var_dump($rating);
var_dump($accountID);


if(!mysql_query("UPDATE Spreadsheet SET rating='$rating' WHERE accountID='$accountID'")) {echo 1;}

}    
mysql_close();
?>

Thanks so much! This question has been bothering me for a bit. I have tried many Google attempts, but I could not find an answer as specific as I am asking. Thank you so much.

  • 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-15T13:10:13+00:00Added an answer on June 15, 2026 at 1:10 pm

    Answer to #1:

    You can use Javascript/AJAX to accomplish submitting the form without actually pressing submit. There are various javascript libraries that can help you accomplish this a lot easier than bare bones Javascript, namely jQuery ( http://jquery.com/ ). It’s not a very complicated task but you will need to learn some basic Javascript and how to use jQuery. The essential flow of things would be when the form changes, submit an AJAX request to submit the form. You will need a second script to take the incoming AJAX request and do the save. Try search engines for some basic jQuery tutorials, and once you have a basic grip, something like “ajax submit on form change jquery” will get you started.

    Answer to #2:

    Something like this (please see my notes…)

    echo '<select name="rating" id="rating">';
    $q = mysql_query("SELECT `option_name` FROM `options`");
    while($row = mysql_fetch_assoc($q)) { 
        echo '<option value="' . $row['option_name'] . '">' . $row['option_name'] . '</option>';
    }
    echo '</select>';
    

    If you would like the select preselected, that’s pretty easy too! Taking from the last example:

    $pre_selected = "Very Bad";
    echo '<select name="rating" id="rating">';
    $q = mysql_query("SELECT `option_name` FROM `options`");
    while($row = mysql_fetch_assoc($q)) { 
        echo '<option value="' . $row['option_name'] . '"';
        if($row['option_name'] == $pre_selected) { 
          echo ' selected="selected"';
        }
        echo '>' . $row['option_name'] . '</option>';
    }
    echo '</select>';
    

    But this is the part I’d like to point a few things out:

    • Don’t use the old mySQL library like you are using and my examples are using. Please, use PDO, or at least mySQLi. The functions you are using are deprecated, and may not be available in PHP for much longer.
    • Please, escape your data properly. Search for “SQL Injection” and you will find a massive amount of information about how your code is very insecure (your UPDATE, specifically) because you did not escape the values.
    • Just a heads up, when/if you use jQuery, you’re going to need to use id="foo" in addition to name="foo".
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

and thanks for taking the time to read my question. We will have visitors
I would like to begin by thanking you all for taking time to try
Thinking about avoiding code replication, I got a question that catches me every time
thank you for taking your time Problem I have a problem with searching records
First, thanks for taking the time to read this. I'm having some difficulties with
I have a list of tuples that contains a tool_id, a time, and a
I have this question in my online QUIZ since i am doing my degree
So i have been taking a Computer science course that uses C+ to teach
I was taking a look at Star Schema Benchmark and then I was thinking
Once again I need your Help, am thanking you as every time you helped

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.