当从控制器呈现两位数的数组到查看页面时,数组仅显示第一个个位数值
视图/视图1.php
<a class="btn btn-success" href="index.php?r=followusers/follow&id=<?= $follower1, $followed1; ?>" >Follow</a>
控制器
public function actionFollow($id)
{
$model = Followusers::findOne($id);
return $this->render('follow', [
'model' => $model, 'id' => $id,
]);
查看/关注.php
Yii::$app->db->createCommand()
->insert('followusers', [
'follower' => $id[0],
'followed' => $id[1],
])->execute();
Yii::$app->response->redirect(['user/view1','id' => $id[1]]);
}
当 $follower 1 或 $followed 1 分配 10 时,单击"关注"按钮时,它只对 ID 取 1为什么会发生 我的代码
中是否有任何错误提前致谢
我在将参数传递给 url 时实际上犯了错误,应该以这种方式完成
<a class="btn btn-success" href="index.php?r=followusers/follow&id=<?= $follower1;?>&usr=<?= $followed1;?>" >Follow</a>
instead of above in the view1.php