I am trying to access a user in a database based on their id. The id is auto incremented and thus unknown to the person accessing the user. I have created the functions below for accessing user information:
Expand|Select|Wrap|Line Numbers
- function get_user_by_id($user) {
- global $connection;
- $query = "SELECT * ";
- $query .= "FROM person ";
- $query .= "WHERE personid=" . $user['id'] ." ";
- $query .= "LIMIT 1";
- $result_set = mysql_query($query, $connection);
- confirm_query($result_set);
- if ($user = mysql_fetch_array($result_set)) {
- return $user;
- } else {
- return NULL;
- }
- }
- And the function below uses the one above.
- function find_selected_user() {
- global $user;
- if (isset($_GET['id'])) {
- //get all info for user in database
- $user = get_user_by_id($_GET['personid']);
- } else {
- //user doesn't exist in database -- return null?
- $user = NULL;
- }
- }.
Does anyone know why the user is not being updated? (I am assuming it is because the user is not even accessed).
Any help would be greatly appreciated!
Please let me know if I can clarify/elaborate on the question