我的工作(在冷杉时间)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