Search the Community
Showing results for tags 'elseif'.
-
Hello guys! I have literally started learning how to code. And I have come to the point when I got to deal with elseif syntax which is not working properly and messes up everything I have done so far. Here's the script $password = "tulip"; if ($password == "tulip") { echo '<b>Hello!</b><br> Welcome to the website Blaise!'; } else { echo '<b> The password or login is incorrect <br> Please try again </b>'; } elseif ( $password == "daisy") { echo '<b> Welcome Kate! </b>; } When I type in "daisy" nothing goes on and everything just gets stuck. Any help or explanation? Thanks
-
PHP newb here - apologies if the answer to this is really simple. I've tried to add a geotargetting code into my website but it appears the elseif part isn't working, no matter what I do. Here's the code - any idea why if is fine, and else is fine, but elseif isn't? <?php if (function_exists('showCountryContentInPage')) { if(showCountryContentInPage(array("us", "ca"),1)) { // US $region = 'USA'; $country = codediesel_get_users_country(); $store_url = 'URL here'; } elseif(showCountryContentInPage(array("at", "es", "cy", "fi", "ee", "fr", "de", "el", "ie", "it", "mt", "lu", "lv", "nl", "pt", "sk", "si", "be"),1)) { // Europe $region = 'Europe'; $country = codediesel_get_users_country(); $store_url = 'URL here'; } else { // UK $region = 'UK'; $country = codediesel_get_users_country(); $store_url = 'URL here'; } ?>
-
Hi folks, relative newbie so my code wont be pretty, however... This one has me stumped. I have written some PHP to change the background colour of a cell in a table based on a variable. The code is as follows: // Convert Summer 8 Grade to a number value if ($row['Sum8']=='1a') { $sum8_value=3; } elseif ($row['Sum8']=='1b') { $sum8_value=2; } elseif ($row['Sum8']=='1c') { $sum8_value=1; } elseif ($row['Sum8']=='2a') { $sum8_value=6; } elseif ($row['Sum8']=='2b') { $sum8_value=5; } elseif ($row['Sum8']=='2c') { $sum8_value=4; } elseif ($row['Sum8']=='3a') { $sum8_value=9; } elseif ($row['Sum8']=='3b') { $sum8_value=8; } elseif ($row['Sum8']=='3c') { $sum8_value=7; } elseif ($row['Sum8']=='4a') { $sum8_value=12; } elseif ($row['Sum8']=='4b') { $sum8_value=11; } elseif ($row['Sum8']=='4c') { $sum8_value=10; } elseif ($row['Sum8']=='5a') { $sum8_value=15; } elseif ($row['Sum8']=='5b') { $sum8_value=14; } elseif ($row['Sum8']=='5c') { $sum8_value=13; } elseif ($row['Sum8']=='6a') { $sum8_value=18; } elseif ($row['Sum8']=='6b') { $sum8_value=17; } elseif ($row['Sum8']=='6c') { $sum8_value=16; } elseif ($row['Sum8']=='7a') { $sum8_value=21; } elseif ($row['Sum8']=='7b') { $sum8_value=20; } elseif ($row['Sum8']=='7c') { $sum8_value=19; } elseif ($row['Sum8']=='N') { $sum8_value=0; } elseif ($row['Sum8']=='X') { $sum8_value=25; } elseif ($row['Sum8']=='B') { $sum8_value=5; } elseif ($row['Sum8']=='-') { $sum8_value=150; } // Calculate progress for Summer 8 $sum8_progress = number_format(($ks3_target_value-$ks2_value)*0.75)+$ks2_value; $sum8_progress_final = $sum8_value-$sum8_progress; if ($sum8_progress_final< -1) { $progress_colour_sum8="#ac3845";} elseif ($sum8_progress_final==-1) { $progress_colour_sum8="#c5a751";} elseif ($sum8_progress_final==0) { $progress_colour_sum8="#93a336";} elseif ($sum8_progress_final>= 1 && $sum8_progress_final<= 34) { $progress_colour_sum8="#477dae";} elseif ($sum8_progress_final>= 35) { $progress_colour_sum8=$row_color; } If you can follow my code, the problem is that currently $sum8 = '-' for every entry in the table and therefore working everything through the cell should end up being $row_color which is basically grey. However it is showing up as #477dae This code works on every other column in my table (the only difference being sum8 is spr8, aut8, sum7, spr7 etc etc (for autumn, spring, summer year 7, 8, 9 etc etc. It is only the sum8 based column that does not work. I have echo'd the results to check and find the following: $sum8_progress_final is in the 100's for every result $progress_colour_sum8 however is #477dae for every result? Any suggestions or thoughts?