Spartan 117 Posted February 28, 2007 Share Posted February 28, 2007 Hello, I am trying to make a page where an admin can edit a part of a user. I want the page to first display a list of a certain type of users. So first I just use a while loop: <?php include "config.php"; // connect to the mysql server $link = mysql_connect($server, $db_user2, $db_pass2) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database2) or die ("Could not select database because ".mysql_error()); //If cmd has not been initialized if(!isset($cmd)) { //display all the links $result = mysql_query("SELECT * FROM smf_members order by ID_GROUP desc"); //run the while loop that grabs all the news scripts while($r=mysql_fetch_array($result)) { //grab the title and the ID of the news $name=$r["MemberClanName"];//take out the title $id=$r["ID_MEMBER"];//take out the id //make the title a link echo "<a href='rpoints.php?cmd=edit&ID_MEMBER=$id'>$name</a>"; echo "<br>"; } } ?> But I would like it to filter through those results so it only shows users that are in certain groups. I want it to check a row called "ID_GROUPS" and see if the number is a 9 or a 1 and if so keep those, but get rid of the rest. Is this possible to do, and if so how would I accomplish it? Thanks Link to comment https://forums.phpfreaks.com/topic/40531-solved-while-loop-with-filter/ Share on other sites More sharing options...
monk.e.boy Posted February 28, 2007 Share Posted February 28, 2007 $result = mysql_query("SELECT * FROM smf_members WHERE id_groups=9 OR id_groups=1 ORDER BY ID_GROUP desc"); monk.e.boy Link to comment https://forums.phpfreaks.com/topic/40531-solved-while-loop-with-filter/#findComment-196161 Share on other sites More sharing options...
Spartan 117 Posted February 28, 2007 Author Share Posted February 28, 2007 Thanks a lot, it works great! Link to comment https://forums.phpfreaks.com/topic/40531-solved-while-loop-with-filter/#findComment-196170 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.