I am very new to PHP programming and I will be very thankful if anyone kindly help me out regarding the error message that I am getting on the following code snippet:
<option value="<?php echo $rowMC['id']; ?>" <?php echo (isset($_POST['MainContract']) && $_POST['MainContract'] === '<?php echo $rowMC['id']; ?>' ? 'selected' : ''; ?> > <?php echo $rowMC['MainContract']; ?> </option>
I have checked several time that there are not any missing ; in the lines before or after and I think sth is wrong with the posted code snippet.
Advertisement
Answer
use this :
<option value="<?= $rowMC['id']; ?>" <?= isset($_POST['MainContract']) && $_POST['MainContract'] === $rowMC['id'] ? 'selected' : '' ?> > <?= $rowMC['MainContract']; ?> </option>