Yahiya
Yahiya

Reputation: 791

Map enum values fetched from database to string to view on website php

I have in my database a column named bodybuild which can have varchar(2) datatype values ('1','2','3') where 1= six apck 2= fat and 3= thin

How should i map the output coming from my function i.e 1 as sixpack in my view page for view??

if (! empty($timeline['bodybuild'])) {
$bbt = \SocialKit\UI::view('timeline/user/info-bodybuild-row');
$themeData['info_bodybuild_row'] = $bbt; }

Here the variable $bbt contains the enum values. It may be 1 or 2 or 3. I use simple PHP and underscore.js for my website work. I created this variable $bbt for an example.

{{INFO_BODYBUILD_ROW}} is used to view the value in my view page

Please help and thank you in advance...

Upvotes: 1

Views: 160

Answers (1)

BeetleJuice
BeetleJuice

Reputation: 40896

$bbt = \SocialKit\UI::view('timeline/user/info-bodybuild-row');
$bbt = ($bbt == 1) ? 'six pack' : ($bbt == 2 ? 'fat' : 'thin');

Now you can use $bbt

Upvotes: 1

Related Questions