mardi 30 avril 2019

Php Function how to turn integer into varchar on the output

Hi im new here and also just start learn programming.

I'm creating pdf file from my web project, there is 1 integer coloumn in my table which the value is 0,1,2

the output in pdf is number but i want to change the number into text.

example if the "Status" is 1 the output is "Approved", if "Status" is 2 the ouput is "Declined", and if the "Status" is 0 the ouput is "on process"

  function fetch_data()  
  {  
  $output = '';  

  $conn = mysqli_connect("localhost", "root", "", "system");  

  $sql = "SELECT Status from tabel";  

  $result = mysqli_query($conn, $sql);

  while($row = mysqli_fetch_array($result))  
  {       
  $output .= '<tr> 
                <td>'.$row["Status"].'</td>  
              </tr>  
                      ';  
  }  
  return $output;  
  }

Aucun commentaire:

Enregistrer un commentaire