Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从php数组创建html单选按钮列表?_Php_Html_Mysql - Fatal编程技术网

如何从php数组创建html单选按钮列表?

如何从php数组创建html单选按钮列表?,php,html,mysql,Php,Html,Mysql,我有以下代码(这是一段更大的代码): 像这样尝试: <?php while($row = mysql_fetch_assoc($result5)) { $options[] = $row['vasuts']; } ?> <html> <br> <form method="post" action="answering.php"> <?php foreach($options as $option=>$option_valu

我有以下代码(这是一段更大的代码):

像这样尝试:

<?php
  while($row = mysql_fetch_assoc($result5)) {
    $options[] = $row['vasuts'];
}
?>
<html>
<br>
<form method="post" action="answering.php">
<?php 
foreach($options as $option=>$option_value) {
    ?>
   <input type="radio" name="<?= $option; ?>"><?php echo $option_value?><br>

<?php }?>
<input name= "submit" type="submit" value="Vasta">
</form>
<form method="post" action="answering.php">
    <?php foreach ($options as $key => $value): ?>
        <input type="radio" name="<?php echo $key; ?>" /><?php echo $value; ?><br />
    <?php endforeach; ?>
    <input name= "submit" type="submit" value="Vasta">
</form>


试着这样做:

<?php
  while($row = mysql_fetch_assoc($result5)) {
    $options[] = $row['vasuts'];
}
?>
<html>
<br>
<form method="post" action="answering.php">
<?php 
foreach($options as $option=>$option_value) {
    ?>
   <input type="radio" name="<?= $option; ?>"><?php echo $option_value?><br>

<?php }?>
<input name= "submit" type="submit" value="Vasta">
</form>
<form method="post" action="answering.php">
    <?php foreach ($options as $key => $value): ?>
        <input type="radio" name="<?php echo $key; ?>" /><?php echo $value; ?><br />
    <?php endforeach; ?>
    <input name= "submit" type="submit" value="Vasta">
</form>



尝试使用下面的代码

<html>
    <br>
    <form method="post" action="answering.php">
        <?php
        foreach ($options as $key => $value) {
            ?>
            <input type="radio" name="<?php echo $key; ?>"><?php echo $options[$key] ?><br>
            <?php
        }
        ?>


        <input name= "submit" type="submit" value="Vasta">
    </form>
</html>



尝试使用下面的代码

<html>
    <br>
    <form method="post" action="answering.php">
        <?php
        foreach ($options as $key => $value) {
            ?>
            <input type="radio" name="<?php echo $key; ?>"><?php echo $options[$key] ?><br>
            <?php
        }
        ?>


        <input name= "submit" type="submit" value="Vasta">
    </form>
</html>



您可以使用for each来执行此操作,如下所示:

<?php
  while($row = mysql_fetch_assoc($result5)) {
    $options[] = $row['vasuts'];
}
?>
<html>
<br>
<form method="post" action="answering.php">
<?php 
foreach($options as $option=>$option_value) {
    ?>
   <input type="radio" name="<?= $option; ?>"><?php echo $option_value?><br>

<?php }?>
<input name= "submit" type="submit" value="Vasta">
</form>
<form method="post" action="answering.php">
    <?php foreach ($options as $key => $value): ?>
        <input type="radio" name="<?php echo $key; ?>" /><?php echo $value; ?><br />
    <?php endforeach; ?>
    <input name= "submit" type="submit" value="Vasta">
</form>


您可以使用for each来执行此操作,如下所示:

<?php
  while($row = mysql_fetch_assoc($result5)) {
    $options[] = $row['vasuts'];
}
?>
<html>
<br>
<form method="post" action="answering.php">
<?php 
foreach($options as $option=>$option_value) {
    ?>
   <input type="radio" name="<?= $option; ?>"><?php echo $option_value?><br>

<?php }?>
<input name= "submit" type="submit" value="Vasta">
</form>
<form method="post" action="answering.php">
    <?php foreach ($options as $key => $value): ?>
        <input type="radio" name="<?php echo $key; ?>" /><?php echo $value; ?><br />
    <?php endforeach; ?>
    <input name= "submit" type="submit" value="Vasta">
</form>

为此使用for循环:

for($i=1;$i
为此使用for循环:

for($i=1;$i