OOP PHP Return Custom String

PHP OOP Return String Based on Input

Here is an OOP PHP sample which inputs the age of each entry and returns a custom string based on the age of each person.

<?php

class age_level {

public $score;
public $course;

public function __construct($age_input) {

$this->score = $age_input;
}

public function convert_age(){
//set property values equal to strings based on age
if ($this->score>='1' && $this->score<='12') {

$this->course = "Kid";
return $this->course;

}

elseif ($this->score>='13' && $this->score<='19') {

$this->course = "Teen";
return $this->course;

}

else if ($this->score>='20' && $this->score<='29'){

$this->course = "Twenties";
return $this->course;

}

else if ($this->score>='30' && $this->score<='39'){

$this->course = "Thirties";
return $this->course;

}

else if ($this->score>='40' && $this->score<='49'){

$this->course = "Forties";
return $this->course;

}

else if ($this->score>='50' && $this->score<='59'){

$this->course = "Fifties";
return $this->course;

}

else if ($this->score>='60' && $this->score<='69'){

$this->course = "Sixties";
return $this->course;

}

else if ($this->score>='70' && $this->score<='79'){

$this->course = "Seventies";
return $this->course;

}

else if ($this->score>='80' && $this->score<='100'){

$this->course = "Senior";
return $this->course;

}

}

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html class="gecko win" lang="en-gb" xml:lang="en-gb" xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>

<div id="scores">
<?php
echo "<b>Users</b><br/><br/>";
?>
<ul style="margin:0px; padding:0px;">
<?php
//include ('class_program_level.php');
$command = "select * from table_sort ORDER BY date DESC";
$result = mysqli_query($db, $command);
if ($result && mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$age_input=$row['age'];
$myage = new age_level($age_input);
$bg =($bg=='#A7C6BA' ? '#f9f9f9' : '#A7C6BA');
echo "<li style=\"padding:0px 10px 10px 10px;background: $bg;\"><span style=\"font-size:18px;display:none;\"><b>".$row["firstname"]."</b></span><br/><b>First Name:</b> ".$row["firstname"]."<br/><b>Last Name:</b> ".$row["lastname"]."<br/><b>Email:</b> ".$row["email"]."<br/><b>Height:</b> ".$row["height"]."<br/><b>Age:</b> ".$row["age"]."<br/><b>Weight:</b> ".$row["weight"]."<br/><b>Age Category:</b> ".$myage->convert_age().  "</li>";
}

}
?>
</ul></div>

<div style="clear:both;"></div>

</body>
</html>