title: php html select value
body: <p>I have a select box connect to database for countries, it works but trying to keep the selected data in the form clears itself out. I have tried adding a selected but gives error</p>
  
  <pre><code>&lt;div class="form-group"&gt;
                      &lt;label&gt;Country&lt;/label&gt;
          &lt;?php
          $sql = "SELECT * FROM countries ";
          $result = query($sql);
          ?&gt;
          &lt;select class="form-control input-lg box" id="country"  name="country"&gt;
                          &lt;option value=""&gt;Select a country&lt;/option&gt;                      
          &lt;?php
          $i = 0;
          while (($row = mysqli_fetch_assoc($result)) != false) {
              ?&gt;
          &lt;option value="&lt;?=$row["country_id"];?&gt;"&gt;&lt;?=$row["country_name"];?&gt;&lt;/option&gt;
          &lt;?php
              $i ++;
          }
          ?&gt;        
          &lt;/select&gt;
                  &lt;/div&gt; 
  </code></pre>