大家好我正在查询mysql表并使用php在前端显示结果。但我未能按用户过滤数据,即我只想根据当前用户ID显示结果。
数据库连接
$mysqli = new mysqli ('*******', '******', '*******', '******');
$current_user = get_user_id();
$sql = "SELECT Results FROM `assessments` where User_ID = current_user";
if ( value < 50 ) {
echo "You need to improve";
} else {
echo " Good Work ";
}
我的表格如下
User_ID Results
20 59
27 47
28 60
30 60
答案 0 :(得分:1)
你在current_user之前错过了一个$。试试:
$sql = "SELECT Results FROM `assessments` where User_ID = $current_user";