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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:29:39+00:00 2026-05-30T03:29:39+00:00

I have a php page that has a few HTML questions on it, each

  • 0

I have a php page that has a few HTML questions on it, each question has a “type” and you answer that question on a scale of 1-5, In the example below there would be 3 question types: A, B, & C. How can I add the TOTAL score for each question “type”(score is made from the radio buttons for the 1-5 scale below each question) and then have those total scores stored as PHP variables?

Here is the HTML code, I have NO CLUE where to start but I need to make this for a school event we are doing soon and I don’t wanna let them down 🙂 Haha! Thanks for all the help guys, sorry I know so little about HTML forms! Anyways, here’s the HTML code, the php can go anywhere I haven’t written it yet /: haha:

Type A rating:
<br>
<form action="" method="post">
1
<input type="radio" name="select" value="1">
<input type="radio" name="select" value="2">
<input type="radio" name="select" value="3">
<input type="radio" name="select" value="4">
<input type="radio" name="select" value="5">
5
</form>
<br><br>
Type B rating:
<br>
<form action="" method="post">
1
<input type="radio" name="select" value="1">
<input type="radio" name="select" value="2">
<input type="radio" name="select" value="3">
<input type="radio" name="select" value="4">
<input type="radio" name="select" value="5">
5
</form>
<br><br>
Type A rating:
<br>
<form action="" method="post">
1
<input type="radio" name="select" value="1">
<input type="radio" name="select" value="2">
<input type="radio" name="select" value="3">
<input type="radio" name="select" value="4">
<input type="radio" name="select" value="5">
5
</form>
<br><br>
Type C rating:
<br>
<form action="" method="post">
1
<input type="radio" name="select" value="1">
<input type="radio" name="select" value="2">
<input type="radio" name="select" value="3">
<input type="radio" name="select" value="4">
<input type="radio" name="select" value="5">
5
</form>
<br><br>
Type A rating:
<br>
<form action="" method="post">
1
<input type="radio" name="select" value="1">
<input type="radio" name="select" value="2">
<input type="radio" name="select" value="3">
<input type="radio" name="select" value="4">
<input type="radio" name="select" value="5">
5
</form>
<br><br>
Type B rating:
<br>
<form action="" method="post">
1
<input type="radio" name="select" value="1">
<input type="radio" name="select" value="2">
<input type="radio" name="select" value="3">
<input type="radio" name="select" value="4">
<input type="radio" name="select" value="5">
5
</form>
<br><br>
Type B rating:
<br>
<form action="" method="post">
1
<input type="radio" name="select" value="1">
<input type="radio" name="select" value="2">
<input type="radio" name="select" value="3">
<input type="radio" name="select" value="4">
<input type="radio" name="select" value="5">
5
</form>
<br><br>

<input type="submit" name="Sum The Ratings" value="Vote">
  • 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-30T03:29:42+00:00Added an answer on May 30, 2026 at 3:29 am

    Create a big form with all the questions in it, then for each question, set the name of the input with a keyword different for each questions. When you will treat your form, you will get with $_POST[‘name’] the value selected, just add them and make a ration or wathever you wan’t

    <?php
    $name_cat_a = "A_";
    $name_cat_b = "B_";
    $cat_a_quest = array("Question A1", "Question A2");
    $cat_b_quest = array("Question B1", "Question B2");
    if(!isset($_POST[submit])){
    echo '<form action="test.php" method=post>';
    echo 'Type A rating:';
    echo '<br />';
    $ind = 0;
    foreach($cat_a_quest as $question){
        echo $question;
        echo '<br>';
        $name = $name_cat_a . $ind;
        $ind ++;
        for($i=0;$i<5;$i++){
        echo '<input type="radio" name="'.$name.'" value="'.($i+1).'" />'.($i+1) ;
        }
        echo '<br />';
    }
    echo 'Type B rating:';
    echo '<br />';
    $ind = 0;
    foreach($cat_b_quest as $question){
        echo $question;
        echo '<br>';
        $name = $name_cat_b . $ind;
        $ind ++;
        for($i=0;$i<5;$i++){
        echo '<input type="radio" name="'.$name.'" value="'.($i+1).'" />'.($i+1);
        }
        echo '<br />';
    }
    echo '<input type="hidden" name="submit" value="1" />';
    echo '<input type="submit" name="Sum The Ratings" value="Vote">';
    echo '</form>';
    }
    else{
    $moyen_a = 0;
    $moyen_b = 0;
    $nmb_ques_a = count($cat_a_quest);
    $nmb_ques_b = count($cat_b_quest);
    for($i=0; $i<$nmb_ques_a; $i++){
         $moyen_a = $moyen_a + intval($_POST['A_'.$i]);
    }
    $moyen_a = $moyen_a / $nmb_ques_a;
    for($i=0; $i<$nmb_ques_b; $i++){
         $moyen_b = $moyen_b + intval($_POST['B_'.$i]);
    }
    $moyen_b = $moyen_b / $nmb_ques_b;
    
    
    echo 'A:'.$moyen_a.'<br />';
    echo 'B:'.$moyen_b.'<br />';
    }
    ?>
    

    There i have explicitely name cat_a and cat_b but you can put all your cat in an array, then you loop into it, in this loop, you loop while ther is questions, and then you loop for the 5 answers

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

Sidebar

Related Questions

I have a website that has an index.php, a few simple .html pages and
I am working with php and want to have a page that has a
I have a PHP page that returns a piece of HTML to set the
I have a php page that displays rows from a mysql db as a
I have a PHP page that I run every minute through a CRON job.
I have a PHP page that does a couple of different things depending on
I have a php page that takes in a bunch of url parameters and
I have a PHP page that queries a DB to populate a form for
I have a particular PHP page that, for various reasons, needs to save ~200
The Idea I have a main PHP page that loads content in DIV's from

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.