我的工作(在冷杉時間)MVC模式和顯示錯誤警告,當我遇到一些問題時顯示錯誤...不知道如何使用的foreach
例如我這
控制器:
include_once(UserModel.php);
$userdata = new User_Model();
$biography = $userdata->Get_UserBio();
型號:
include_once(conexion.php);
//I make my prepared query and...
if ($user_infoprofile->execute()):
$data= $user_infoprofile->get_result();
if ($data->num_rows):
while ($result=$data->fetch_array()):
$this->userbio[]=$result;
endwhile;
else:
//I want to display something like
$error= "you have to fill your bio",
echo $error;
endif;
else:
$error="invalid request";
echo $error;
endif;
return $this->userbio;
$user_infoprofile->close();
查看:
include_once(UserController.php);
//if there are rows in the array I display
foreach...
//But heres my problem... if there are not rows in the array... I want to display something else
我該怎麼辦?我在這方面是初學者,還是有其他更乾淨的方法來做到這一點?
一個小錯誤 $ error =「你必須填寫你的生物」,在這裏你以逗號結尾,只是以分號結尾並嘗試 – Umar