Hello,
I come to you because I need help on request ...
I have a rank table that lists all the ranks available to a player with the maximum number of points for the rank.
I have another table users who list my players with their experience.
I want to use the experience of players to display the rank corresponding to the experience.
Example :
[b]rank table[/b]
| id | grade | point |
__________________________
| 1 | Niveau 1 | 300 |
| 2 | Niveau 2 | 600 |
users table
| id | name | experience |
______________________________
| 1 | test | 330 |
So if my player has an experience of 330 I need to display a level of 2 because above 300 and below 600.
PHP Code:
/*
// This works if I enter the experience value directly
$this->db->select('*')
->from('rank')
->where('point >=', 1200);
*/
// This not work I can't arrive to get the experience user
$this->db->select('*')
->from('rank')
->where('point >=', "SELECT 'experience' FROM 'users' WHERE 'name' = $username");
$query = $this->db->get();
if($query->num_rows()>0)
{
return $query->row_array();
}