如何为列表中的每个项目放置一个输入广播?

问题描述 投票:-1回答:1

我需要输入一个输入无线电来选择我的列表中的项目在php或codeigniter中。

<ul>                    
 <?php

    foreach($modalities_actors as $mod_act){
    echo "<li>";
        echo "<input type='radio'>$mod_amu</input>";
    echo "</li>";
}
?>

</ul>
php codeigniter
1个回答
0
投票

这里是从数据库表id获取值的组合框的代码。

$sql = "SELECT * FROM `pregunta_multi` WHERE 1 ORDER BY pregunta_multi.Id_preg_multi";

if($result = mysqli_query($link, $sql)){
    if(mysqli_num_rows($result) > 0){
 echo "<label class='col-xs-3 control-label'>Id_preg_multi</label>";
    echo "<div class=styled-select blue semi-square>";   
 echo "<select class='js_inline_input' name='Id_preg_multi' for='Id_preg_multi' >";


           while ( $row =mysqli_fetch_assoc($result)) {
  echo "<option id='Id_preg_multi' name='Id_preg_multi' value='".$row['Id_preg_multi']."'>".$row['Id_preg_multi']."</option>";
}
        echo "</select>";
   echo "</div>";

} }  

mysqli_close($link);

组合框示例

enter image description here

代码单选按钮



if($result = mysqli_query($link, $sqlm)){
    if(mysqli_num_rows($result) > 0){

        while($row = mysqli_fetch_array($result)){

       }

        mysqli_free_result($result);
    } else{
        echo "Nada no DB";
    }
} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

echo "<div class='tbl-header'>";
  echo "<table class='bordered' cellpadding='0' cellspacing='0' border='0'>";
        echo "<thead>";
                echo "<tr>";

                echo "<th width=900px>Pergunta #1</th>";


            echo "</tr>";
            echo "</thead>";
echo "</table>";



if($result = mysqli_query($link, $sql)){
    if(mysqli_num_rows($result) > 0){

         echo "<div class='tbl-content'>";
        echo "<table class='table'>";

        while($row = mysqli_fetch_array($result)){

            echo "<tbody>";
            echo "<tr>";
                echo "<td width=700px bgcolor='#e6e6e6'>". $row['Descricao']. "<br><br></td>";
    echo "<form class=form-horizontal method=post >";

?>  

 <?php 
echo "<input type=hidden class=form-control id=Nota1 name=Nota1 value='".$row['Nota']."' >";

       echo "<input type=hidden class=form-control id=Id_papsignup name=Id_papsignup value='".$userRow['Id']."' >";
echo "<input type=hidden class=form-control id=Id_teste name=Id_teste value=2 >";
echo "<input type=hidden class=form-control id=Nota_final name=Nota_final value=0 >";
echo "<input type=hidden class=form-control id=rad name=rad value=0 >";
echo "<input type=hidden class=form-control id=rad2 name=rad2 value=0 >";
echo "<input type=hidden class=form-control id=rad3 name=rad3 value=0 >";
echo "<input type=hidden class=form-control id=rad4 name=rad4 value=0 >";
echo "<input type=hidden class=form-control id=rad5 name=rad5 value=0 >";
echo "<input type=hidden class=form-control id=rad6 name=rad6 value=0 >";
echo "<input type=hidden class=form-control id=rad7 name=rad7 value=0 >";
echo "<input type=hidden class=form-control id=rad8 name=rad8 value=0 >";
echo "<input type=hidden class=form-control id=rad9 name=rad9 value=0 >";
echo "<input type=hidden class=form-control id=rad10 name=rad10 value=0 >";
 ?> 
<?php 
echo "<tr>";
echo "<td width=100px bgcolor='#f4f4f4'><input type=radio name=rad value=". $row['Nome']. " /><input type=hidden  id=Nome1 name=Nome1 value='".$row['Nome']."' >". $row['Nome']. "</td>";
       echo "</tr>";
echo "<tr>";
echo "<td width=100px bgcolor='#f4f4f4'><input type=radio name=rad value=5 /><input type=hidden  id=Nomi1 name=Nomi1 value='".$row['Nome1']."' >". $row['Nome1']. "</td>";
       echo "</tr>";
echo "<tr>";
echo "<td width=100px bgcolor='#f4f4f4'><input type=radio name=rad value=50 /><input type=hidden  id=Nomo1 name=Nomo1 value='".$row['Nome2']."' >". $row['Nome2']. "</td>";
      echo "</tr>";
echo "<tr>";
echo "<td width=100px bgcolor='#f4f4f4'><input type=radio name=rad value=10 /><input type=hidden  id=Nomu1 name=Nomu1 value='".$row['Nome3']."' >". $row['Nome3']. "</td>";
           echo "</tr>";


            echo "</tr>";
            echo "</tbody>";
        }
        echo "</table>";
         echo "</div>";
        echo "</div>";
        // Close result set
        mysqli_free_result($result);
    } else{
        echo "Nada no DB";
    }
} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

单选按钮示例

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.