Jump to content

Search the Community

Showing results for tags 'index'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Shortly I need to block a group of users at once according to their role status (banned or not) instead of blocking users one by one. I tried using fk on update cascade to control the role status by making a fk user_role_status column in the users table refers to role_status column in the roles table but without luck because when I change a role status in roles table it changes the whole user_role_status column in users table not only the role I changed then it blocks all users not only the group I want to block because role_status in roles table is not unique and I can't make it unique because its all cells contain value='1', so I deleted the column and gave up that idea // role_status in roles table is a fk refers to id in statuses table. statuses_table id is_active ------------------ 0 no 1 ok roles_table id role role_status -------------------------------------- 1 Admins 1 2 Editors 1 3 Users 1 users_table id user_name user_level --------------------------------------- 1 Admin 1 2 Editor1 2 3 User1 3 4 Editor2 2 5 User2 3 6 User3 3 and this is the function I use -------------------------------------------------------------- Find role status -------------------------------------------------------------- function find_by_current_rolStatus($role_status) { global $db; $sql = "SELECT users.id FROM users JOIN roles ON roles.id = users.user_level WHERE roles.role_status = '{$db->escape($role_status)}'"; $result = $db->query($sql); return($db->num_rows($result) === 0 ? true : false); } -------------------------------------------------------------- Function for checking if user role status banned or allowed -------------------------------------------------------------- function login_require_roleStatus($require_role_status) { global $session; $current_user = current_user(); $current_user_role_status = find_by_current_rolStatus($current_user['role_status']);//line 155 //if Role status Deactive if ($current_user['role_status'] === '0')://line 157 $session->msg('Banned'); redirect('home.php',false); //if user role allowed elseif($current_user['role_status'] === '1')://line 161 return true; endif; } and I got this error I am trying to get the users whose user_level = role_id which its status = '0' or '1', I checked this SQL query with phpmyadmin and it is working fine, and actually I don't know what to do after that :( , I mean I don't know what to write with $current_user['role_status'] instead of role_status to get what I want.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.