I have a feeling this is really simple. Here's the deal: I have a table with three columns. I want to take all the values in one of the columns and turn that into a list. I want to do this so I can transverse through the list. Each value in the list corresponds to a username. I want to take that username to access info about a user. Using this info, I can check which faculty the user is in and sort accordingly. This is what I've come up with:
function get_users_by_faculty($faculty) {
global $connection;
$query = "SELECT * FROM owner";
$user_set = mysql_query($query); // ERROR could not establish link to server
confirm_query($user_set);
foreach($user_set as $user) { //ERROR invalid argument
$userFaculty = get_info_by_id($user["ownerId"], "ou");
if($faculty == $userFaculty){
return $user["name"];
} else {
return NULL;
}
}
I've been quite stuck on this for a few hours.
mysql_*functions in new code. They were removed from PHP 7.0.0 in 2015. Instead, use prepared statements via PDO or MySQLi. See Why shouldn't I use mysql_* functions in PHP? for more information.WHEREclauses. Your code is equivalent of going to a grocery store, buying up the entire store's inventory, driving home, then throwing it all out because you only wanted a chocolate bar.