I am using PHP to check the sql data, but if I am using variable to write in the sql code, it can't get the result in the page.
Below is my coding, if I put the variable is $user_id, it can't get the result to see:
<?php
$sql_incharge = 'select * from user_permission where user_id='.$user_id' and menu_id=228';
$arr_incharge = db_conn_select($sql_incharge);
//print_r($arr_incharge);
foreach ($arr_incharge as $rs_incharge) {
$test88 = $rs_incharge['is_edit'];
echo $test88;
}
?>
What I have tried:
- If I hardcode the number replace $user_id, it can get the result.
- If without menu_id ,like this code
'select * from user_permission where user_id='.$user_id
, it can get the result.
But I want two condition (user_id and menu_id) to check my record, hope anyone can guide me how to show the record when I am using variable.