I have a site that has the 50 US States and I would like to have that States flag show when it is selected.

Would this work if not what needs to be added or deleted?

<?php if (is_file("city/$xcityid.gif")) { include("city/$xcityid.gif"); }
?> 

$xcityid is the variable that calls from the dB the State name.

    you want want include, should be the html ie <img src= ...

      <?php
      
      // goping on "$xcityid is the variable that is mysql_query for State name." State name = Alabama? or 2?
      $states = array("alabama", "alaska"); 
      foreach($states as $numberRepresentingState => $state)
      {
          if($state==$xcityid)
          {
              $xcityidNo = $numberRepresentingState;
              break;
          }
      }
      
      //alabama would be 2, alaska would be 3
      // so below alabama would be 2.gif
      
      if (file_exists("city/".$imgId.".gif"))
      {
          echo "<img src=\"city/".$imgId.".gif\" width=\"80\" height=\"80\" alt=\"".$xcityid." state flag\" />";
      }
      ?>

      What about this?

        djdubuque;10931336 wrote:

        What about this?

        what about it?

          dagon;10931337 wrote:

          what about it?

          Please do not wast my time, if you have not read the question don't answer.

            Forgive the above but being offensive does not make what you want any clearer, just posting a piece of code and saying "what about this?" is not going to get you very far.

            Here is a handy tutorial on how to ask a question. How To Ask Questions The Smart Way

              Is it better to place this as a question?

              I have a site that has the 50 US States and I would like to have that States flag show when I select that state. How should the code be written in PHP to pull the query from the dB on what flag to display?

                I answered post i in post 2.

                In post 3, the 2nd php code snippet, you ask: "What about this?"

                Well what about it? what are you asking in relation to that code?

                  Why do you persist on wasting my time? I've asked this same question on another forum and I'm receiving more help from there then you seem to comprehend. If you don't know or understand don't get involved!

                    Your right i don't understand; however I was trying to find the question in your post, so I could help. There is no need to be nasty to people who are trying to help.

                      <?php 
                      
                      // goping on "$xcityid is the variable that is mysql_query for State name." State name = Alabama? or 2? 
                      $states = array("alabama", "alaska"); 
                      foreach($states as $numberRepresentingState => $state) 
                      { 
                          if($state==$xcityid) 
                          { 
                              $xcityidNo = $numberRepresentingState; 
                              break; 
                          } 
                      } 
                      
                      //alabama would be 2, alaska would be 3 
                      // so below alabama would be 2.gif 
                      
                      if (file_exists("city/".$imgId.".gif")) 
                      { 
                          echo "<img src=\"city/".$imgId.".gif\" width=\"80\" height=\"80\" alt=\"".$xcityid." state flag\" />"; 
                      } 
                      ?> 
                      

                      I think that should work, haven't tested it cause really I don't need a snippet like this, although, I don't think i can find a problem with that.

                      I would definitely design a function that you can call that relates to all images required by the site and a separate function that verifies the the files existence thus saving duplicated code. image class of some sort.

                      Getting back to point though, that 'should' work.

                        wait where is the $imgID coming from. I see no referance. Sorry about double post

                          Neville1985;10931434 wrote:

                          wait where is the $imgID coming from. I see no referance. Sorry about double post

                          Not sure, this was the code that was given to me and it didn't work. This is why I posted it here to get more input. I repost this with three files showing some of the Vars.

                            Write a Reply...