How to create different types of input depends upon their position. For example the following data below. For every nominees with president and vice-president position display radio type of button and if senator position display check box.
I do the following way but does not work.
+----------------------------------------------------+
|candidatesid | studentsname | position |
+----------------------------------------------------+
|1 |Demnok Lannik |SENATORS |
|2 |Aurel Vlaicu |SENATORS |
|3 |Rizzrack |SENATORS |
|4 |Ymir |SENATORS |
|5 |Raigor Stonehoof |SENATORS |
|6 |Kardel Sharpeye |VICE-PRESIDENT |
|7 |Purist Thunderwrath |VICE-PRESIDENT |
|8 |Razzil Darkbrew |VICE-PRESIDENT |
|9 |Aggron Stonebreak |PRESIDENT |
|10 |Rylai Crestfall |PRESIDENT |
+----------------------------------------------------+
RESULT
PRESIDENT
O Aggron Stonebreak
O Rylai Crestfall
VICE-PRESIDENT
O Razzil Darkbrew
O Purist Thunderwrath
O Kardel Sharpeye
VICE-PRESIDENT
[ ] Demnok Lannik
[ ] Aurel Vlaicu
[ ] Rizzrack
[ ] Ymir
[ ] Raigor Stonehoof
MY SOLUTION
if ($row['position'] = PRESIDENT) {
$data. = ' < div class = "radio" >
< label > < input class = "p"
type = "radio"
name = "radio"
value = "'.$row['studentsid'].'" > '.$row['
s_name '].' < /label> < /div>';
}
elseif($row['position'] = VICE - PRESIDENT) {
$data. = '<input type class="vp" type="radio" name="radio" value="'.$row['studentsid'].
'" />'.$row['s_name'].
'<br>';
}
elseif($row['position'] = SENATORS) {
$data. = '<input class="single-checkbox" type="checkbox" name="vehicle" value="'.$row['studentsid'].
'">'.$row['s_name'].
'<br>';
} else {
///
}
Aucun commentaire:
Enregistrer un commentaire