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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:29:22+00:00 2026-05-22T22:29:22+00:00

HTML: <form> <input type=radio name=grade value=95 /> A<br /> <input type=radio name=grade value=85 />

  • 0

HTML:

<form>
    <input type="radio" name="grade" value=95 /> A<br />
    <input type="radio" name="grade" value=85 /> B<br />
    <input type="radio" name="grade" value=75 /> C<br />
    <input type="radio" name="grade" value=65 /> D<br />
    <input type="radio" name="grade" value=50 /> F
</form>

PHP:

if (isset($_POST['grade'])) {
                    $name = $_POST['name'];
                    $grade = $_POST['grade'];
                    $sql = "UPDATE grade SET 
                    total=total+'$grade',
                    numvotes=numvotes+1 WHERE
                    name='$name'";

Hi everyone… I’m working on a project to add grades associated with names on a menu. My HTML code for the radial menu for the grade is above and my relevant SQL is shown as well. I want to add a NUMBER VALUE from the grade onto the “total” in my SQL database and increase the number of votes by 1. I’m not sure if my syntax is correct because the database neither gets an addition to its votes or grade total.
Thanks!

EDIT: Part of the reason why I’m confused that this doesn’t work is b/c when I go into the mySQL console, I can do an almost identical command (where instead ‘$grade’ is a number) and it works. In the least I should get an error or maybe the numvotes should increase, but nothing.

EDIT2: Credit to Radu for catching this. My name menu doesn’t function properly. After using $die after my SQL statement, I found that the names being selected from the dropdown menu were being interpreted as integers, not names. It is to be populated by the SQL names in the database. Here is my code.

<?php
    $query = mysql_query("SELECT name, id FROM grade");
    echo "<select name='name'>";
        while ($temp = mysql_fetch_assoc($query)) {
            echo "<option value='".$temp['name']."'>".$temp['name']."    </option>";
        }
    echo "</select>";
?>

EDIT3: After changing $temp['id'] to $temp['name'], I found that my die($sql) now reads:

UPDATE grade SET total=total+'95', numvotes=numvotes+1 WHERE name='charlie'

So the name is going in, but it’s STILL not getting updated. Ideas?

  • 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-22T22:29:23+00:00Added an answer on May 22, 2026 at 10:29 pm

    You’re using names as strings in the SQL query. So change the following:

    echo "<option value='".$temp['id']."'>".$temp['name']."</option>";
    

    to:

    echo "<option>".htmlspecialchars($temp['name'])."</option>";
    

    For live projects, always use htmlspecialchars() when echo()ing something to the browser, and always use mysql_real_escape_string() when composing SQL queries from user input.

    For example, in a live project, you should always use $name = mysql_real_escape_string($_POST['name']) instead of simply $name = $_POST['name'].

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

Sidebar

Related Questions

For the following HTML: <form name="myForm"> <label>One<input name="area" type="radio" value="S" /></label> <label>Two<input name="area" type="radio"
I have the following HTML: <form id=test> <input type=radio value=A name=C1/> <a href=javascript:selectCheckbox('C1', 'A');>
I have the following HTML <form id=create_form name=create_form action= method=post> <input name=type id=type value=individuel
When you do the following in an HTML form: <input name=one[] value=foo /> <input
I've inherited a Courseware CD with thousands of <form action=page.html method=get><input type=submit value=Go></form> buttons.
If a HTML form contains multiple input fields: <form> <input id=in1 type=text value=one> <input
The default decorator for the Zend_Form_Element_Radio is <label for=type_id-1><input type=radio name=type_id id=type_id-1 value=1>Pack</label> The
Harmiih really helped me with my script (http://stackoverflow.com/questions/7510546/html-form-name-php-variable). Basically I have a table with
I am implementing an HTML form with some checkbox input elements, and I want
Let's say I have an html form. Each input/select/textarea will have a corresponding <label>

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.