Note that there are some explanatory texts on larger screens.

plurals
  1. POChange Output in Table based on SQL Query Result
    primarykey
    data
    text
    <p>I am trying to change the printed result in two columns in the table based on whether the column from the sql query is a 0 or a 1 </p> <p>I did an echo of $Status and it puts a list of correct values out, but it is above my table. Am I going about this incorrectly, to place it into my table rows?</p> <p>The rest of my data populates the table correctly, it is just those two columns. I currently have that portion commented out, and so the output into the table is a 0 or 1 respectively. I also have next to the specific column, a commented out variable of where they would be if they were to be correctly outputting.</p> <p>Any help would be greatly appreciated.</p> <p>Here is the portion of the code where I am trying to do the conversion:</p> <pre><code>if ($strAdjIncrease == '0') { $AdjIncDec == 'Decrease'; } elseif ($strAdjIncrease == '1') { $AdjIncDec == 'Increase'; } else { $AdjIncDec == 'Unknown'; } if ($strAdjStatus == '0') { $Status =='Open'; } elseif ($strAdjStatus == '1') { $Status =='Closed'; } else { $Status =='Void'; } </code></pre> <p>Here is my Full Table Code:</p> <pre><code>if (odbc_num_rows($rsIaL) == 0) { echo "&lt;center&gt;"; echo "&lt;b&gt;We're Sorry, No Records Returned.&lt;/b&gt;&lt;br&gt;\n"; echo "&lt;/center&gt;"; } else { echo "&lt;p align='center'&gt;"; echo "&lt;font face='Arial' size='4'&gt;&lt;b&gt;Last 31 Days Only&lt;/b&gt;&lt;/font&gt;"; echo "&lt;/p&gt;\n"; echo "&lt;table border='1' align='center' cellpadding='2' style='border-collapse: collapse; font-size: 12px; font-weight: bold'&gt;\n"; echo "&lt;thead&gt;"; echo "&lt;tr&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;#&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;Log ID&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;Reason&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;Inc/Dec&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;Status&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;Ref No&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;Tot Cost&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;Tot Retail&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;Start&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;End&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;th ALIGN='LEFT' bgcolor='#C0C0C0'&gt;&lt;font face='Arial' size='2'&gt;&lt;b&gt;User&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;"; echo "&lt;/tr&gt;"; echo "&lt;/thead&gt;"; echo "&lt;tbody&gt;"; $counter = 1; while ($row = odbc_fetch_array($rsIaL)) { $strAdjID = trim(odbc_result($rsIaL, "AdjID")); $strReaDesc = trim(odbc_result($rsIaL, "ReaDesc")); $strAdjStatus = trim(odbc_result($rsIaL, "AdjStatus")); $strAdjRefNo = trim(odbc_result($rsIaL, "AdjRefNo")); $strAdjStTS = trim(odbc_result($rsIaL, "AdjStTS")); $strAdjEndTS = trim(odbc_result($rsIaL, "AdjEndTS")); $strAdjUID = trim(odbc_result($rsIaL, "AdjUID")); $strAdjTotCost = trim(odbc_result($rsIaL, "AdjTotCost")); $strAdjTotRetail = trim(odbc_result($rsIaL, "AdjTotRetail")); $strAdjIncrease = trim(odbc_result($rsIaL, "AdjIncrease")); if ($bgcolor == '#ffffff') { $bgcolor = '#dddddd'; } else { $bgcolor = '#ffffff'; } /* I can't get this if/else portion to work and output correctly to the table! I may be doing it incorrectly though if ($strAdjIncrease == '0') { $AdjIncDec == 'Decrease'; } elseif ($strAdjIncrease == '1') { $AdjIncDec == 'Increase'; } else { $AdjIncDec == 'Unknown'; } if ($strAdjStatus == '0') { $Status =='Open'; } elseif ($strAdjStatus == '1') { $Status =='Closed'; } else { $Status =='Void'; } */ echo "&lt;tr&gt;\n"; echo "&lt;td bgcolor = '$bgcolor' align=center&gt;$counter&lt;/td&gt;\n"; echo "&lt;td bgcolor = '$bgcolor' align=center&gt; &lt;a href='Inventory_Adjustments_Detail.asp?log_id=$strAdjID&amp;store_id=$storeID'&gt;$strAdjID&lt;/a&gt;&lt;/td&gt;\n"; echo "&lt;td bgcolor = '$bgcolor' align=left&gt;$strReaDesc&lt;/td&gt;\n"; echo "&lt;td bgcolor = '$bgcolor' align=left&gt;$strAdjIncrease&lt;/td&gt;\n"; #$AdjIncDec &lt;-if/else variable echo "&lt;td bgcolor = '$bgcolor' align=left&gt;".$strAdjStatus."&lt;/td&gt;\n"; #$Status &lt;- if/else variable echo "&lt;td bgcolor = '$bgcolor' align=left&gt;$strAdjRefNo&lt;/td&gt;\n"; echo "&lt;td bgcolor = '$bgcolor' align=right&gt;$" . number_format($strAdjTotCost, 2) . "&lt;/td&gt;\n"; echo "&lt;td bgcolor = '$bgcolor' align=right&gt;$" . number_format($strAdjTotRetail, 2) . "&lt;/td&gt;\n"; echo "&lt;td bgcolor = '$bgcolor' align=center&gt;" . date('n-j-Y h:i:s A', strtotime($strAdjStTS)) . "&lt;/td&gt;\n"; echo "&lt;td bgcolor = '$bgcolor' align=center&gt;" . date('n-j-Y h:i:s A', strtotime($strAdjEndTS)) . "&lt;/td&gt;\n"; echo "&lt;td bgcolor = '$bgcolor' align=left&gt;$strAdjUID&lt;/td&gt;\n"; echo "&lt;/tr&gt;"; $counter++; } echo "&lt;/tbody&gt;\n"; echo "&lt;/table&gt;&lt;br&gt;\n"; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload