Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7531447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:10:27+00:00 2026-05-30T05:10:27+00:00

Im trying to write a script to display images based on if there is

  • 0

Im trying to write a script to display images based on if there is an entry form a database for example if a text string has ABC an image will be displayed. I got that part correctly but now the problem is if there is no text sting that matches abc i want a blank image outputted for example if there are no text strings that contain abc there will be either no output or a blank image. Here is the code i have been working on.

 <?php
     //Begin Airline List
                //FAA ident only eg AAH = Aloha
                if (strpos($e[0],'AAH') !==false){
                $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/aah.png"/>';}
                if (strpos($e[0],'AAL') !==false){
                $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/aal.png"/>';}
                if (strpos($e[0],'SWA') !==false){
                $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/swa.png"/>';}
                if (strpos($e[0],'UAL') !==false){
                $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/ual.png"/>';}
                if (strpos($e[0],'HAL') !==false){
                $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/hal.png"/>';}
                if (strpos($e[0],'DAL') !==false){
                $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/dal.png"/>';}
                if (strpos($e[0],'ASA') !==false){
                $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/asa.png"/>';}
                if (strpos($e[0],'TRS') !==false){
                $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/trs.png"/>';}
                if (strpos($e[0],'KAP') !==false){
                $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/kap.png"/>';}
                if (strpos($e[0],'CHQ') !==false){
                $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/chq.png"/>';}
// this is where i want to code for if there is no matching text strings                
else (strpos($e[0],'CHQ','AAH','AAL','SWA','UAL','HAL','DAL','ASA','TRS','KAP','CHQ') ===false)
                die $cs='<img src="http://www.virtual-aviation.org/main/map/alogos/blank.png"/>';



                //End Airline Listing


    ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:10:28+00:00Added an answer on May 30, 2026 at 5:10 am

    The best thing to do in these situations is to separate your logic from your data.

    <?php
        // Begin Airline List
        // FAAident only eg AAH = Aloha
        $airlines = Array('AAH', 'AAL', 'SWA', 'UAL', 'HAL', 'DAL', 'ASA', 'TRS', 'KAP', 'CHQ'); 
    
        $current = 'blank';
        $search = 'something aah something'; // $e[0];
        foreach ($airlines as $airline) {
            if ( stripos($search, $airline) !== false ) {
                $current = $airline;
                break;
            }
        }
    
        $image = '<img src="http://www.virtual-aviation.org/main/map/alogos/' . $current . '.png"/>';
    
        //End Airline Listing
    ?> 
    

    Just set $search to the $e[0] variable you have and all will work. I also use stripos for case insensitivity, but this isn’t required if you can guarantee capital case. Note that this is a much better method than an if else situation and even a switch case situation because all you’re feeding in is an array and you don’t need to change any code structure at all to add or remove airlines. All you will ever need to touch is that array up the top – which is exactly what you want – to keep your code dynamic and short and allow data to be changed as needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a script that informs the user when someone has logged
I'm trying to write a script to display the current time on a page
I'm trying to write a script to allow me to log in to a
I'm trying to write a script that will create a user in MediaWiki, so
I'm trying to write a script that allows an admin of a photo uploading
I'm trying to write a script that will download files from an FTP server.
I'm trying to write a script that searches a directory for files and greps
I am trying to write a script which uploads a file via a html
I'm trying to write a small script to change the current directory to my
I'm trying to write a python script that packages our software. This script needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.