Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.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 如何向yii中的mysql表发送多个值_Php_Mysql_Yii_Foreach - Fatal编程技术网

Php 如何向yii中的mysql表发送多个值

Php 如何向yii中的mysql表发送多个值,php,mysql,yii,foreach,Php,Mysql,Yii,Foreach,我不熟悉PHP和Yii框架。如何在数据库中插入多个问题 这是表单视图代码 <?php echo $form->textField($model,'questions',array('id'=>"content_#index#_question textBox")); ?> <?php echo $form->textField($model,'questions',array('id'=>"content_#index#_question textBo

我不熟悉PHP和Yii框架。如何在数据库中插入多个问题

这是表单视图代码

<?php echo $form->textField($model,'questions',array('id'=>"content_#index#_question textBox")); ?>

<?php echo $form->textField($model,'questions',array('id'=>"content_#index#_question textBox")); ?>
实际上,我的过程是创建多个问题和答案,但现在出现了如下错误

“为foreach()提供的参数无效”,通过使用我的代码以及如何向mysql表发送多个问题和答案…

试试这个

 <?php echo $form->textField($model,'questions[]',array('id'=>"content_#index#_question textBox"));  ?>

更改此选项

foreach ($model['questions'] as $value) {
                $model->questions = $value;

            }
            $model->save();
关于这个

foreach ($model['questions'] as $value) {
                $model->questions = $value;
                $model->save();
            }

你想做什么?插入一个问题的多个答案。或者插入问题和答案栏我必须插入多个问题和答案,但这里我只提到了问题。谢谢你的回答,我确实按照你说的做了更改,但现在只插入了一行。。。
foreach ($model['questions'] as $value) {
                $model->questions = $value;
                $model->save();
            }