Jump to content

[SOLVED] While Loop With Filter?


Spartan 117

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.