Jump to content

How to display checkbox group as part of if statement


bluewater

Recommended Posts

Can someone show me the correct code to display a group of checkbox values as part of an if statement? For example: in Programme One, lesson 100, lesson 310 and lesson 102 are available. In Programme Two, lesson 302, lesson 201, and lesson 102 are available. The "lesson types" are a checkbox group. I need to output the lesson types depending on whether they are part of Programme One or Two, along with other variables such as instructor student ratio.

 

I put the following code together where field_lessons is the checkbox group;

 

      <?php

        if ($fieldsObjects['field_type']->data == "Programme One") {

          print '<p class="details_heading03">Instructor Student Ratio</p>';

          echo $fieldsFormatted['field_student_ratio']. '<br />';

          foreach ($fieldsObjects['field_lessons']->data as $name => $value) {

          echo $value;

          echo "<br/>";

        }

        else {

          echo "no";

        }

        ?>

 

I have also tried using this statement:

 

      <?php

        if ($fieldsObjects['field_type']->data == "Programme One") {

          print '<p class="details_heading03">Instructor Student Ratio</p>';

          echo $fieldsFormatted['field_student_ratio']. '<br />';

          echo (isset($fieldsObjects['field_lessons']->data) &&

          is_array($fieldsObjects['field_lessons']->data)) ?

        }

        else {

          echo "no";

        }

        ?>

 

I am new to php, and I am customising a template which is part of Sobi2, which has been installed as a component of Joomla! (CMS)?

 

Thank you

 

jo

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.