IE9 and FF not displaying HTML code generated from PHP.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bajaexplorer
    New Member
    • Dec 2012
    • 3

    IE9 and FF not displaying HTML code generated from PHP.

    In both IE9 and FF.

    I have two php routines in a web page. Both are alike except variables. Both will output the HTML <options> for <select> in both routines. Have verified the source at the browser for both. But the first one is not displaying.

    The correct HTML code is in the browser and have saved it as a htm file. Running this file, the web page does display correctly, with the proper 'selected' option.

    first one not working:

    Code:
    <tr>
     <td align="left">State/Province
      <span id="star">*</span>
     </td>
     <td align="left">
     <div id="shipping_to_state_div" style="float:left">
     <select id="shipping_to_state_prov" name="shipping_to_state_prov">
    
    <?php
    $sql = "SELECT * FROM state WHERE country='".$country."'";
    $data_assoc_array = $db->getQuery($sql);
    $data_num_rows    = $db->num_rows;
    echo '<option value="">Select State_Prov</option>';
    for( $indx = 0; $indx < $data_num_rows; $indx++ )
    {
      echo '<option value="'.$data_assoc_array[$indx]['ID'].'"';
    
      if( $data_assoc_array[$indx]['ID'] == $shipping_to_state_prov )
      {
        echo ' selected';
      }
      echo ' >'. $data_assoc_array[$indx]['title']. '</OPTION>'."\n";
    }
    ?>
    </SELECT>
    </div>
    </td>
    </tr>
    Second one working:
    Code:
    <tr>
    <td align="left">State/Province
      <span id="star">*</span>
    </td>
    <td align="left">
    <div id="shipping_to_state_div" style="float:left">
    <select id="shipping_to_state_prov" name="shipping_to_state_prov">
    <?php
     $sql = "SELECT * FROM state WHERE country='".$country."'";
     $data_assoc_array = $db->getQuery($sql);
     $data_num_rows    = $db->num_rows;
     echo '<option value="">Select State_Prov</option>';
     for( $indx = 0; $indx < $data_num_rows; $indx++ )
     {
       echo '<option value="'.$data_assoc_array[$indx]['ID'].'"';
    
       if( $data_assoc_array[$indx]['ID'] == $shipping_to_state_prov )
       {
         echo ' selected';
       }
       echo ' >'. $data_assoc_array[$indx]['title']. '</OPTION>'."\n";
     }
    ?>
    </SELECT>
    </div>
    </td>
    </tr>
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    bajaexplorer:

    And just what exactly is "not working" in the first code vs. the second block of code. What errors (if any)? What is it you want the code to do?

    Comment

    • bajaexplorer
      New Member
      • Dec 2012
      • 3

      #3
      I thought I explained it very well.
      Neither EI9 nor FF is displaying the HTML code generated by one of the PHP routine. There are two PHP routines, both alike except for the variables.

      Looking at the source code in browser, the <select> <options> and 'selected' are there for both routines. But one of them is not display in the browser.

      in other words:

      Code:
      <select id="state_prov" name="state_prov">
      <option value="">Select State_Prov</option>
      <option value="32" >Alabama</OPTION>
      <option value="73" >South Dakota</OPTION>
      <option value="74" selected >Tennessee</OPTION>
      <option value="75" >Texas</OPTION>
      </SELECT>
      <
      None of it is being shown in one of the two fields in the browser.

      Even tho this is what is in for browser source.
      The web pages two columns only have one that is display the state 'Tennessee'.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        I thought you said they were mostly the same except for the variable names? But when I look at the two code samples you posted, the variables are the same as well. Are you sure you posted the right code?

        Comment

        • bajaexplorer
          New Member
          • Dec 2012
          • 3

          #5
          Yes, I copied the wrong one. Forgive me for that.
          But what gets me, is why is it in the browser as HTML correctly, but still will not display.
          Like I had mentioned, if i save that source from the browser and click on the htm file of it. It pops up showing correctly.

          If this was any other app, I would think I had a race condition.

          Code:
          <tr>
          <td align="left">State/Province:<span id="star">*</span></td>
          <td align="left">
          <div id="state_div" style="float:left">
          <select id="state_prov" name="state_prov">
          <?php
             $sql = "SELECT * FROM state WHERE country='".$country."'";
             $data_assoc_array = $db->getQuery($sql);
             $data_num_rows    = $db->num_rows;
             echo ' <option value="">Select State_Prov</option>';
             for( $indx = 0; $indx < $data_num_rows; $indx++ )
             {
                echo '<option value="'.$data_assoc_array[$indx]['ID'].'"';
          
                if( $data_assoc_array[$indx]['ID'] == $state_prov )
                {
                   echo ' selected';
                }
                
                echo ' >'. $data_assoc_array[$indx] ['title']. '</OPTION>'."\n";
             }
          ?>
          </SELECT>
          </div>
          </td>
          </tr>

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            I don't see in your code how the variables $country, $shipping_to_st ate_prov, and $state_prov is being populated.

            Comment

            • zmbd
              Recognized Expert Moderator Expert
              • Mar 2012
              • 5501

              #7
              bajaexplorer

              And that is why I asked the question I did... HTML is not one of the languages I use often; thus, I thought I had missed something.
              Last edited by zmbd; Dec 7 '12, 04:06 PM. Reason: [Z{fixed grammer :) }]

              Comment

              • sharpcoders
                New Member
                • Dec 2012
                • 2

                #8
                My be columns your are calling is not exists. check the columns carefully in table of the database.
                Secondly try selected="selec ted" instead of selected

                Comment

                Working...