Checking array value and adding corresponding css class

Asked

Viewed 41 times

0

I am developing an odontogram and in the registration form which tooth or teeth will be made the treatment. These choices are recorded in a column and a flag 0 in another column relating that that dental treatment has not yet been performed. Taking for example:
column teeth | column flag
               13 0
          17,18 0 0
        11,15,21 1
If zero treatment is open, has not yet been performed and a class will be inserted for the tooth to be red, if 1, a green class will be inserted for that tooth, the treatment has been performed and if there is no tooth will be added gray class.

What I’m not getting is to relate each tooth to its flag and add the corresponding class. For each tooth on the front in the form will be called this function and will verify that that tooth passed as parameter is registered and will mark it with the corresponding color. I am able to find the tooth, but I am not able to understand a condition for it to add the class matches whether or not there is the tooth corresponding to its flag. The idPatient and Teeth variable are passed by parameter in the function.

`

 $query = $this->db2->select( 'treatment_teeth, treatment_flag' )->from( 'tbl_enchiridion_treatment' )

 ->where( 'treatment_id_patient', $idPatient )->get()->result();

 $store = '';

  foreach( $query as $v )
  {
    $store .= $v->treatment_teeth . ',';
  }

  $substr = substr( $store, 0 , -1 );       

  if( in_array( $teeth, explode( ",", $substr ) ) )
  {
    return 'odontogram-tooth-on-process';

  }else{

    return '';
  }

}`

  • Put the HTML your controller uses

  • @Andreicoelho is very HTML, I can put it in the Pastebin and post the link here?

  • No... put only the part you want to change the HTML class. And if you can, enter what you tried to do.

  • I will post only then some blocks of 2 teeth html, from 23 to 24, but remembering that they are all teeth, so I said that the HTML code is huge. But I call in each block the function to check if that tooth is registered and in what condition it is. I will post in another comment because here will exceed the size, but even so will not give the size here, I can answer my question by putting the code?

  • You can’t... =/ ... The answer is only for the answer. It goes like this... If it got too big... Put the part you want to change, make it clear... And put the big code even after.... At the end of the question, you write: Full html code. If it doesn’t fit, put it on some download link...

  • This is a block <div class="odontogram-tooth-image-23 <?= $this->patient->checkTeeth($patient[0]->id_pt, 23); ?>"></div>&#xA;<div class="odontogram-number odontogram-number-23">23</div> !Where I pass the client id and tooth as parameters and for each tooth have these blocks with the same function to check the corresponding tooth.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.