2016-07-14 4 views
0

のボタンからコントローラします通過アレイはyii2

public function actionFollow($id) 
{ 
    $model = Followusers::findOne($id); 
       return $this->render('follow', [ 
      'model' => $model, 'id' => $id, 
      ]); 

ビュー/ follow.php

Yii::$app->db->createCommand() 
->insert('followusers', [ 
'follower' => $id[0], 
'followed' => $id[1], 
])->execute(); 

Yii::$app->response->redirect(['user/view1','id' => $id[1]]); 
} 

は$ follower1または$ followed1は10が割り当てられているときにのみ、私は実際に行われ

+0

を行うべきであるURLにパラメータを渡しながら、間違い。 ?> "これを取得した結果を教えてください...私はURLが生成されているのが好きです.. – scaisEdge

+0

http://localhost/series/index.php?r = followusers/follow&id = 210 // here $ follower = 2 $は= 10 –

答えて

0

私のコードのいずれかの失態は、事前に
おかげであり、フォローボタン、それが発生している理由 をクリック上のIDに1を取ります??それはあなたがHREF = "index.phpを、R = followusers /従ってください&ID = <= $ follower1、$ followed1を意味するものを私に説明することができます。このようにし

<a class="btn btn-success" href="index.php?r=followusers/follow&id=<?= $follower1;?>&usr=<?= $followed1;?>" >Follow</a> 
         instead of above in the view1.php