have php/MySQL-derived html table cell display certain string depending on MySQL column value -


i have html table built using php displaying mysql data so:

current html table (displaying mysql data) sg # |  customer | required date | reject value | rev. cat. | reject reason |  [#]  | [cust. 1] |     [date]    |    [$$$$]    |   [data]  |      [#]      | [#]  | [cust. 1] |     [date]    |    [$$$$]    |   [data]  |      [#]      | [#]  | [cust. 1] |     [date]    |    [$$$$]    |   [data]  |      [#]      | 

right now, column called "reject reason" has data pulled mysql column "fault" has type of int (that set reference code - ex: 34 = "damaged in shipping"). so, when reference column, number code returned. want set kind of if statement say:

if ([table].fault == '[a #]') {   $rejectreason = "[reason corresponding number]" } if.... on , forth possible returned numbers. 

i want display $rejectreason value in html table reason corresponds fault value row.

i'm not sure how this.

my code:

    //select statement build table.     $sql="select invoices.id, clients.company, invoices.revenue, format(trim(leading '$' invoices.totalprice), 2) totalprice, invoices.requireddate, invoices.rej_value, invoices.fault      invoices inner join clients on invoices.clientid=clients.id     ".$whereclause."      order invoices.id desc";      //and (invoices.requireddate between '".$rejectfrom."' , '".$rejectto."')       //select statement build table.     //$sql2="select company, revenue, id, trim(leading '$' totalprice) totprice, requireddate, rej_value     //  invoices      //  ".$whereclause."     //  group ".$orderbyclause."";       $result = $conn->query($sql);        //$result2 = $conn->query($sql2);       echo "<table id='rejectreport' align='center' class='report_dt'>     <thead>     <tr>       <th>sg number</th>     <th>customer</th>     <th>required date</th>     <th>reject value</th>     <th>revenue category</th>     <th>reject reason</th>     </tr>     </thead>";        if ($result = $conn->query($sql)) {              // fetch associative array              while ($row = $result->fetch_assoc()) {                  $rejectreason = "";             //an attempt @ solving problem...           /*           if ($row['fault'] = '00') {               $rejectreason = "no code selected";           }           if ($row['fault'] = '10') {               $rejectreason = "broken (equipment)";           }           if ($row['fault'] = '11') {               $rejectreason = "broken (shipping)";           }           if ($row['fault'] = '20') {               $rejectreason = "scratches";           }           if ($row['fault'] = '21') {               $rejectreason = "bubbles";           }           if ($row['fault'] = '22') {               $rejectreason = "crazing";           }           if ($row['fault'] = '23') {               $rejectreason = "warp";           }           if ($row['fault'] = '24') {               $rejectreason = "burnout";           }           if ($row['fault'] = '30') {               $rejectreason = "broken (worker)";           }           if ($row['fault'] = '31') {               $rejectreason = "slippage";           }           if ($row['fault'] = '32') {               $rejectreason = "dirty";           }           if ($row['fault'] = '33') {               $rejectreason = "incorrect layup";           }           if ($row['fault'] = '34') {               $rejectreason = "incorrect size";           }           if ($row['fault'] = '35') {               $rejectreason = "incorrect assy";           }           if ($row['fault'] = '36') {               $rejectreason = "debris";           }          if ($row['fault'] = '40') {               $rejectreason = "other";          }           else {               $rejectreason = "";           }              */           print_r($rejectreason);                  echo "<tbody>";               echo "<tr>";               //echo "<td>" . $row['id'] . "</td>";               if($row['id']) echo "<td><a href='../bms/workorders_addedit.php?id=".$row['id']. "' target='_self'>".$row['id']." </a></td>";               echo "<td>" . $row['company'] . "</td>";               echo "<td>" . $row['requireddate'] . "</td>";               echo "<td>" ."$". $row['rej_value'] . "</td>";               echo "<td>" . $row['revenue'] . "</td>";               echo "<td>" . $row['fault'] . "</td>";               }//end while.               echo "</tr>";               echo "</tbody>";                /*               while ($row = $result2->fetch_assoc()) {                    echo "<tfoot class='report_dt'>                         <tr>                         <th>totals: </th>                         <th>$". $row['rpttotprice'] ."</th>                         <th>". $row['rpttotsqft'] ."&nbsp;&nbsp;". "ft<sup>2</sup>"."</th>                         <th>$". $row['rptavgsqftrev'] ."</th>                         <th>". $row['rpttotqty'] ."</th>                         <th>$". $row['rptavgunitrev'] ."</th>                         </tfoot>                         </table>";               }//end while.               */    }//end table if. 

all suggestions welcome.

thank you!


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -