PHP: return value of user selected array -
please excuse if duplicate or similar post, have searched on here , not figure out answer question based on previous posts...
i know may noob question (im trying desperately teach myself php please bear me!)
i have custom concrete5 block building (using jordanlev's awesome designer content).
here code:
<?php if ($field_3_select_value == 1): ?> <!-- enter markup here field "heading placement left or right?" : choice "head-left" --> <?php endif; ?> <?php if ($field_3_select_value == 2): ?> <!-- enter markup here field "heading placement left or right?" : choice "head-right" --> <?php endif; ?> <?php if ($field_4_select_value == 1): ?> <!-- enter markup here field "heading placement - top middle bottom" : choice "top" --> <?php endif; ?> <?php if ($field_4_select_value == 2): ?> <!-- enter markup here field "heading placement - top middle bottom" : choice "middle" --> <?php endif; ?> <?php if ($field_4_select_value == 3): ?> <!-- enter markup here field "heading placement - top middle bottom" : choice "bottom" --> <?php endif; ?> <div class="span 7 head <?php echo $field_3_select_value->$value; ?> <?php echo $field_4_select_value->$value; ?>"> <?php if (!empty($field_6_textbox_text)): ?> <h2><?php echo htmlentities($field_6_textbox_text, ent_quotes, app_charset); ?></h2> <?php endif; ?> <?php if (!empty($field_7_textbox_text)): ?> <h2><?php echo htmlentities($field_7_textbox_text, ent_quotes, app_charset); ?></h2> <?php endif; ?> <?php if (!empty($field_8_textbox_text)): ?> <h2><?php echo htmlentities($field_8_textbox_text, ent_quotes, app_charset); ?></h2> <?php endif; ?>
what im trying achieve value of $field_3_select_value
& $field_4_select_value
appear content of array in class of div.
next have 3 text boxes inserted (if filled in user) styled according classes on div above.
is possible? need build 'foreach' loop , if so, can point me in right direction? prefer learn how rather me, , direction , of course constructive criticism appreciated!
thanks in advance :)
you can use switch
:
<?php switch ($field_3_select_value): case 1: $class3 = 'head-left'; break; case 2: $class3 = 'head-right'; break; default: $class3 = ''; endswitch; switch ($field_4_select_value): case 1: $class4 = 'top'; break; case 2: $class4 = 'middle'; break; case 3: $class4 = 'bottom'; break; default: $class4 = ''; endswitch; ?> <div class="span 7 head <?php echo $class3; ?> <?php echo $class4; ?>">
Comments
Post a Comment