Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.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 从数据库数组值构建的表单并没有将单选按钮限制为单个选择_Php_Mysql_Radio Button_Radiobuttonlist - Fatal编程技术网

Php 从数据库数组值构建的表单并没有将单选按钮限制为单个选择

Php 从数据库数组值构建的表单并没有将单选按钮限制为单个选择,php,mysql,radio-button,radiobuttonlist,Php,Mysql,Radio Button,Radiobuttonlist,我试图构建一个表单,其中用户根据数据库表中的值数组选择一个项。下面是我用来过滤列表的代码: $arrlength=count($results); $listSubscriptions = '<form>'; for($x=0; $x<$arrlength; $x++) { $itemList = $results[$x]->item_name; $listSubscriptions .= '<input type="radio" nam

我试图构建一个表单,其中用户根据数据库表中的值数组选择一个项。下面是我用来过滤列表的代码:

$arrlength=count($results);

$listSubscriptions = '<form>';
for($x=0; $x<$arrlength; $x++)
  {
    $itemList =    $results[$x]->item_name;
    $listSubscriptions .= '<input type="radio" name="'.$itemList.'" value="'.$itemList.'"> '.$itemList.'<br>';
  }
  $listSubscriptions .= '</form>';

 return $listSubscriptions;
$arrlength=计数($results);
$listSubscriptions='';
对于($x=0;$xitem\u name;
$listSubscriptions.=''.$itemList.'
'; } $listSubscriptions.=''; 返回$listSubscriptions;

当我打印表单的结果时,我可以让单选按钮按我所希望的方式显示,但问题是选择并不局限于一个单选按钮。你知道为什么吗?

单选按钮必须共享一个
名称
属性才能属于同一组:

$listSubscriptions .= '<input type="radio" name="subscription" value="' . $itemList . '"> ' . $itemList . '<br>';
$listSubscriptions.='.$itemList.
';
单选按钮组必须具有相同的“名称”属性