Php 在HTML中,多个选项分别保存在MySQL逗号中(works),但不会从基于类的读取方法中重新显示

Php 在HTML中,多个选项分别保存在MySQL逗号中(works),但不会从基于类的读取方法中重新显示,php,html,mysql,Php,Html,Mysql,我有以下HTML代码: <tr> <td class="tablecontent" style="background-color: <?= $DATA_COLOR ?>;"> <?= $oLanguage->getExpression('optherapy', 'revisionIndikation', 'Indication') ?> </td> <td class="tablecontent" st

我有以下HTML代码:

<tr>
  <td class="tablecontent" style="background-color: <?= $DATA_COLOR ?>;">
    <?= $oLanguage->getExpression('optherapy', 'revisionIndikation', 'Indication') ?>
  </td>
  <td class="tablecontent" style="background-color: <?= $DATA_COLOR ?>;">
    <select id="op5revindselect" name="cbOP5RevisionIndikation[]" multiple="multiple" data-placeholder="Mehrfachauswahl durch Ctrl/Strg + LMausClick ...">
      <!-- <option><?= $oLanguage->getExpression('optherapy', 'revisionIndikationChoice', 'revision surgery - please choose') ?></option> !-->
      <option value="1" <?=$ optherapie->getOP5RevisionIndikation() == '1' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation1', 'Inner Hernia (Meso)') ?>
      </option>
      <option value="2" <?=$ optherapie->getOP5RevisionIndikation() == '2' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation2', 'Inner Hernia (PETERSON)') ?>
      </option>
      <option value="3" <?=$ optherapie->getOP5RevisionIndikation() == '3' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation3', 'Weight Regain') ?>
      </option>
      <option value="4" <?=$ optherapie->getOP5RevisionIndikation() == '4' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation4', 'Weight Loss Failure') ?>
      </option>
      <option value="5" <?=$ optherapie->getOP5RevisionIndikation() == '5' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation5', 'Stenosis of Anastomosis') ?>
      </option>
      <option value="6" <?=$ optherapie->getOP5RevisionIndikation() == '6' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation6', 'Dysphagia') ?>
      </option>
      <option value="7" <?=$ optherapie->getOP5RevisionIndikation() == '7' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation7', 'Reflux') ?>
      </option>
      <option value="8" <?=$ optherapie->getOP5RevisionIndikation() == '8' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation8', 'Biliary Reflux') ?>
      </option>
      <option value="9" <?=$ optherapie->getOP5RevisionIndikation() == '9' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation9', 'Malnutrition') ?>
      </option>
      <option value="10" <?=$ optherapie->getOP5RevisionIndikation() == '10' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation10', 'Diarrhea') ?>
      </option>
      <option value="11" <?=$ optherapie->getOP5RevisionIndikation() == '11' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation11', 'Gastrogastric Fistula') ?>
      </option>
      <option value="12" <?=$ optherapie->getOP5RevisionIndikation() == '12' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation12', 'Perforation of an Ulcus') ?>
      </option>
      <option value="13" <?=$ optherapie->getOP5RevisionIndikation() == '13' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation13', 'Chronified Ulcus') ?>
      </option>
      <option value="14" <?=$ optherapie->getOP5RevisionIndikation() == '14' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation14', 'Chronified Pain') ?>
      </option>
      <option value="15" <?=$ optherapie->getOP5RevisionIndikation() == '15' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation15', 'Ileus') ?>
      </option>
      <option value="16" <?=$ optherapie->getOP5RevisionIndikation() == '16' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation16', 'Choledocholithiasis after Gastric Bypass ') ?>
      </option>
      <option value="17" <?=$ optherapie->getOP5RevisionIndikation() == '17' ? 'selected' : '' ?>>
        <?= $oLanguage->getExpression('optherapy', 'revisionIndikation17', 'Leakage') ?>
      </option>
    </select>
  </td>
</tr>
现在,读取这些数据的代码如下:

$haveOP1RevisionIndikation = explode(', ', $aBaselineData['OP1RevisionIndikation']);
$this->setOP1RevisionIndikation($haveOP2RevisionIndikation);
但是,这不足以在再次调用页面时以HTML显示输入的值

我认为这最后两行是必不可少的


有人知道如何解决这个问题吗?

因为getter方法将返回数组'3','7','9','16'[用var_dump验证这一点],所以您的条件是

$optherapie->getOP5RevisionIndikation() == '3'
将始终返回false,因为数组“3”、“7”、“9”、“16”!='3'.

您要做的是-检查,而不是相等检查:

<option value="3" <?= in_array('3', $optherapie->getOP5RevisionIndikation()) ? 'selected' : '' ?>>

“工作”?也许我们对“作品”有不同的定义。我的建议是要么规范化您的模式,要么不必麻烦使用关系数据库。首先,我想:您是否启用了错误报告和显示错误?第二个想法:基本行看起来很奇怪,也许当你设置op1revisionindikation时,变量应该是haveOP*1*RevisionIndikation?@Jakumi:谢谢你的评论,我会查看错误输出。
<option value="3" <?= in_array('3', $optherapie->getOP5RevisionIndikation()) ? 'selected' : '' ?>>