Groups and users.....

Discussion in 'PHP' started by D-Fraz, Jun 13, 2008.

  1. #1
    Ok none of the users from a group show. I want all of my members from all of my groups to show but everything is empty.

    <style type="text/css">
    <!--
    .style1 {color: #0033FF}
    .style2 {color: #0044FF}
    .style3 {color: #000000}
    -->
    </style>
    
    <?php include("config.php"); 
    $username = $_SESSION['username']; 
    $result = mysql_query("SELECT usergroup FROM members WHERE username='$username'");
    $row = mysql_fetch_assoc($result); // The results are stored in an sql result array -we need to extract them
    $usergroup = $row['usergroup']; // Since we extracted it into an array, get the correct index of the array
    $result3 = mysql_query("SELECT * FROM members WHERE usergroup='$usergroup'") 
    or die(mysql_error());  
    
    
    // keeps getting the next row until there are no more to get
    while($row = mysql_fetch_array( $result3 )) {
    	// Print out the contents of each row into a table
    	 if ($usergroup == "admin" ) { echo "<span class=\"style1\">{$row['username']}</span>";  
    	 if ($usergroup == "moderator" ) { echo "<span class=\"style2\">{$row['username']}</span>"; 
    	 if ($usergroup == "user" ) { echo "<span class=\"style3\">{$row['username']}</span>"; 
    } 
    }}
    }
    PHP:

    The page is empty. I have tried many things but they don't work properly.
    Admin group should be the color it is. Moderator group should be the color it is and usergroup should be black.

    Please help me out on this one.

    Thank you.
     
    D-Fraz, Jun 13, 2008 IP
  2. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #2
    The algorithm does not seem right. But anyway, try this:

    if ($row['usergroup'] == "admin" ) { echo "<span class=\"style1\">{$row['username']}</span>";       
    if ($row['usergroup'] == "moderator" ) { echo "<span class=\"style2\">{$row['username']}</span>";      
    if ($row['usergroup'] == "user" ) { echo "<span class=\"style3\">{$row['username']}</span>";
    PHP:
    Also, remove:

    usergroup='$usergroup'
    PHP:
    from the query.
     
    Lordo, Jun 13, 2008 IP
  3. D-Fraz

    D-Fraz Peon

    Messages:
    234
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It still shows as empty :(
     
    D-Fraz, Jun 13, 2008 IP