I need to display:
/images/image1.jmp if the number is positive
or
/images/image2.jpg if the number is negative
or
/images/image3 if the number is 0.
$stmt = sqlsrv_query($conn,$sql);
echo "<table border='1'><tr><th>Offense</th><th>Previous Date Range</th><th>Current Date Range</th><th>Difference</th><th>Percentage Difference</><th>Up or down image in this column</></tr>";
while( $row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC) )
{
echo "<tr>";
echo "<td>" . $row['Offense']. "</td>";
echo "<td>" . $row['PreviousDateRange']."</td>";
echo "<td>" . $row['DateRange']."</td>";
echo "<td>" . $row['difference1']."</td>";
echo "<td>" . $row['percentchange']."</td>";
echo "<td>" . $row['']. "</td>";
}
echo "</table>";
?>
I found this code and have tried different ways if incorporating it in the echo "<td>" . $row['']. "</td>
but not having any luck.
I get the code but can not manipulate it to fit what it needs to do. I'm sure it's a simple solution. Just frustrated.
switch ($myNumber) {
case 0:
echo "Zero is not a valid value.";
break;
case $myNumber < 0:
echo "Negative numbers are not allowed.";
break;
default:
echo "Great! Ready to make calculations.";
break;
}
Thanks for the help guys. Got the answer that worked.