Jump to content

Search the Community

Showing results for tags 'elseif'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 3 results

  1. 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
  2. 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'; } ?>
  3. 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?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.