Greetings. How to find out the value of the user in the database through PHP to set the condition - if the value of the user in the database is 'open', then open to allow viewing the profile otherwise, if it is equal to 'close', then block the profile view.
1 answer
Hello! you are accessing an unspecified variable, use the var_dump () function; - Always helps out
$query = mysqli_query($dbConn, "SELECT dostup FROM `Users` WHERE `userid` = '1'"); //Здесь незнаю как правильно парсить - узнать занчение пользователя в столбе "dostup" $row=mysqli_fetch_row($query); $dostup = $row[0]; // Узнаем значение пользователя из столба dostup - open или close - здесь точно ошибка //Если значение open равно значению open пользователя из бд ($dostup), тогда открываем профиль var_dump($query); if ($dostup == "open") { //Тут всё работает } //Если не равняется 'open', равныется 'close', тогда запретить else if ($dostup == "close") { ///Тут будут данные } In general, it is good to forward the database and change the field to numeric 0- access is denied, 1 - access is open. this will save Base space and will not clutter up + the text weighs more (the field itself in the sense reserves more space for itself, but it is more for optimization)
|