function form_processing() { global $first_selected_name; global $second_selected_name; global $given_value; if (isset($_POST['btn'])) { $first_selected_name = $_POST['first_selected_name']; $second_selected_name = $_POST['second_selected_name']; $given_value = $_POST['given_value']; if ($first_selected_name == "Fahrenheit" && $second_selected_name == "Celsius") { $celsious = fahrenheit_to_celsius($given_value); return "Fahrenheit " . $given_value . " = " . $celsious . " Celsius"; } elseif ($first_selected_name == "Celsius" && $second_selected_name == "Fahrenheit") { $fahrenheit = celsius_to_fahrenheit($given_value); return "Celsius " . $given_value . " = " . $fahrenheit . " Fahrenheit"; } elseif ($first_selected_name == "Fahrenheit" && $second_selected_name == "Kelvin") { $kelvin = fahrenheit_to_kelvin($given_value); return "Fahrenheit " . $given_value . " = " . $kelvin . " Kelvin"; } elseif ($first_selected_name == "Kelvin" && $second_selected_name == "Fahrenheit") { $fahrenheit = kelvin_to_fahrenheit($given_value); return "Kelvin " . $given_value . " = " . $fahrenheit . " Fahrenheit"; } elseif ($first_selected_name == "Celsius" && $second_selected_name == "Kelvin") { $kelvin = celsius_to_kelvin($given_value); return "Celsius " . $given_value . " = " . $kelvin . " Kelvin"; } elseif ($first_selected_name == "Kelvin" && $second_selected_name == "Celsius") { $celsius = kelvin_to_celsius($given_value); return "Kelvin " . $given_value . " = " . $celsius . " Celsius"; } elseif ($first_selected_name == "Fahrenheit" && $second_selected_name == "Fahrenheit") { return "Please Select Something to calculate"; } elseif ($first_selected_name == "Celsius" && $second_selected_name == "Celsius") { return "Please Select Something to calculate"; } elseif ($first_selected_name == "Kelvin" && $second_selected_name == "Kelvin") { return "Please Select Something to calculate"; } } else { return "Please Select Something to calculate"; } }
foreach ($all_weather as $key => $val) { ?> <tr> <td><?php echo $key; ?> </td> <td class="text-center"><?php echo '<img src="http://openweathermap.org/img/w/' . $val['weather'][0]['icon'] . '.png">'; ?> </td> <td><?php echo prittify_text($val['weather'][0]['description']); ?> </td> <td><?php echo kelvin_to_fahrenheit($val['main']['temp']) . '°'; ?> </td> </tr> <?php } ?> </tbody> </table> </div> </div> </div> </body> </html>