If the entry in database is 2, then?

Hello, tell me how to make the output from the database to the page records if the id column region_id is equal to 2, output from the base of the Moscow region, if 3, Saint Petersburg. The fact that I have the regions in the database stored numbers but I have to get to the page
June 10th 19 at 15:40
3 answers
June 10th 19 at 15:42
Solution
getRegionNameById function($id){
 $map = [
 '2' => 'Moscow',
 '3' => 'Peter'
];

 return isset($map[$id]) ? $map[$id] : null;
}

echo ($row['region_id']); // 2
getRegionNameById echo($row['region_id')); // Moscow
The error in the code you have( - Joyce.Luettgen commented on June 10th 19 at 15:45
well and gonetoo - Brook_Sawa commented on June 10th 19 at 15:48
June 10th 19 at 15:44
June 10th 19 at 15:46
if
can example to write? - Joyce.Luettgen commented on June 10th 19 at 15:49
if ($region_id === 2) echo 'Moscow' - Brook_Sawa commented on June 10th 19 at 15:52

Find more questions by tags MySQLPHP