Echoing users by group name in PHP
Posted
by
BobSapp
on Stack Overflow
See other posts from Stack Overflow
or by BobSapp
Published on 2011-11-15T17:11:43Z
Indexed on
2011/11/15
17:50 UTC
Read the original article
Hit count: 209
What I want to do is click a name of a group(every group what I create other than poweruser and admin groups) and that will echo all of the users in that group from the database. I have figured out the code so far but now my problem is how will I print it all out when clicking the name of the group?
My code so far is:
<h3>Groups</h3>
<?php
include('db.php');
if (isset($_GET["groupID"])) {
$sql="SELECT `group`.*, `user`.* FROM `user` inner join `group` on group.groupID=user.groupID where group.groupID= " . mysql_real_escape_string($_GET["groupID"]) ;
} else {
$sql="SELECT * FROM `group` WHERE groupName <> 'admin' AND groupName <> 'poweruser'" ;
}
$result=mysql_query($sql,$connection);
while($line=mysql_fetch_array($result)){
echo "<a href='index.php?page=groups&group=".$line['groupID']."'>".$line['groupName'].'</a><br />';
}
mysql_free_result($result);
mysql_close($connection);
?>
© Stack Overflow or respective owner