さて、私はデータベースからサブスクリプションを検証しようとしています (このモデルを他の場所で使用したので、これはうまく機能しているようです)。ただし、返された $data を取得して、ビューで IF ステートメントとして使用しようとしていますが、「if」しようとしている DIV が表示されません。エラーも表示されません。ビューで DIV の周りの IF を削除すると、コンテンツが表示されます...何が間違っていますか?
これが私のコントローラーのコードです:
// Check subscription and display appropriate content if "freebie" package
$subscribe_result = $this -> subscribe_model -> upgrade_message($this->session->userdata('user_id')); // session sends user id to model
$data['subscription'] = $subscribe_result;
モデル:
// Checks to see what package user has subscribed to
public function upgrade_message($id) //$id is session id pulled from controller
{
$this -> db -> select('subscription'); // select the subscription column
$this -> db -> where('id', $id); //find id in table that matches session id
$query = $this -> db -> get("subscriptions"); // connect to this database
return $query->result_array(); //returns the result of the above
}
最後に、出力しようとしているビューの IF ステートメント:
<? if($subscription == 'Freebie') : ?>
<div>some "freebie" content</div>
<? endif ?>