Search code examples
phphtmlselectfpdf

How to display Yes and No instead of binary 1 & 0 in fpdf?


I am creating a pdf using fpdf and posting the input from the form. I want the value 1 0 to be yes No in the pdf.I have use this value 0 1 to do some calculation ....I just want to change in pdf...Now the pdf shows 1 for yes and 0 for No

<select class="form-control" style="width:120px;" name="need">
  <option value="0" <?php prev_select("need", 0); ?>>No</option>
  <option value="1" <?php prev_select("need", 1); ?>>Yes</option>
</select>

<?php
function prev_select($field, $option){
    if (isset($_POST[$field])){
        if ($_POST[$field] == $option){
            ?> selected="true" <?php
        };
    }
}

Solution

  • Replace the 2 options value from 0 and 1 to yes and no

     <select class="form-control" style="width:120px;" name="need">
       <option value="no" <?php prev_select("need", 'no'); ?>>No</option>
       <option value="yes" <?php prev_select("need", 'yes'); ?>>Yes</option>
     </select>