SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SELECT COUNT from multiple tables

    Hello Everybody, i new here and really need some help,

    i have this code which it shows me all the users i have but i created a new module to only show me users from a specific role (ei: admin, supervisor, etc) tthe roles are in another table in my mysql how can i show only user from specific role:

    tableName1 is my users and tableName2 is my roles

    // SETUP PAGING VARIABLE
    // ------------------------------------------------------------
    $tableName1="users";
    $tableName2="users_in_roles";
    $targetpage = "resellers.php";
    $limit = GV_PAGE_SIZE;
    $stages = 2;

    // ------------------------------------------------------------
    // GET DISPLAY QUERY STRING VALUE
    // ------------------------------------------------------------
    if(isset($_GET['display']) && !empty($_GET['display']) && is_numeric($_GET['display']) && $_GET['display'] >= 0 && $_GET['display'] <= 1000)
    {
    $display = strip_tags($_GET['display']);
    $_SESSION['display'] = $display;
    $limit = $_SESSION['display'];
    $remember_limit = $limit;
    }
    else
    {
    $display = $limit;
    }

    /

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2012
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $S mysql_query("SELECT * FROM Users, Roles WHERE Users.ID = Roles.UserID AND Roles.Type = '$Role'") or die(mysql_error()); 
    Not tested but it should work. http://dev.mysql.com/doc/refman/5.0/...imization.html

  3. #3
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    THANKS The fixed didn't work but the reference page helped me a

    Quote Originally Posted by biglittle View Post
    PHP Code:
    $S mysql_query("SELECT * FROM Users, Roles WHERE Users.ID = Roles.UserID AND Roles.Type = '$Role'") or die(mysql_error()); 
    Not tested but it should work. http://dev.mysql.com/doc/refman/5.0/...imization.html
    THANKS The fixed didn't work but the reference page helped me a lot this is what i got

    $query_string = "SELECT COUNT(*) AS TotalCount FROM $tableName2 WHERE RoleID = RoleID#";


    $query_string = "SELECT COUNT(*) AS TotalCount FROM $tableName1";


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •