Radio button rating system in PHP

Asked By 45 points N/A Posted on -
qa-featured

Hi All,

I need to have coding of the radio button rating system in PHP, that will have a few categories of questions that add a score at the end. If anyone of the PHP expert can help me, that will be really helpful for me to refer the coding.

Regards,

Michael B Rodgers

SHARE
Answered By 0 points N/A #166430

Radio button rating system in PHP

qa-featured

This code might help you:

 

<?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" />';

Related Questions