title: Unable to retrieve dropdown data from database while editing in php
body: <p>I'm unable to retrieve dropdown data from database while editing form.
  I'm unable to set the selected option (from database) of  tag in PHP .I'm unable to show the data from database in लेन्डस्केप टाईप dropdown box.
   Please help me.</p>
  
  <p>Here is my existing code:</p>
  
  <pre><code>&lt;?php
  require_once "conn.php";
  if (isset($_GET['id'])) {
  $id = $_GET['id'];
  
  $sql5 = "select * from bps_registration_charkilla where reg_id=" . $id;
  $result5 = mysqli_query($conn, $sql5);
  
  if (mysqli_num_rows($result5) &gt; 0) {
      while($row5 = mysqli_fetch_array($result5)){ ?&gt;
  
      &lt;select name="ch_landscape_type" class="form-control"  value="&lt;?php if (isset($row5['ch_landscape_type'])){ echo $row5['ch_landscape_type'];}?&gt;"&gt;                                                       
           &lt;option value="road" &lt;?php if (!empty($row5['ch_landscape_type'])=="road")echo 'selected' ;?&gt;&gt;सडक&lt;/option&gt;
           &lt;option value="main_road" &lt;?php if (!empty($row5['ch_landscape_type'])=="main_road")echo 'selected' ;?&gt;&gt;मूख्य सडक&lt;/option&gt;
           &lt;option value="dead_end_road" &lt;?php if (!empty($row5['ch_landscape_type'])=="dead_end_road")echo 'selected' ;?&gt;&gt;मुख्य (सडक डेड इन्ड भएको)&lt;/option&gt;
           &lt;option value="ghar" &lt;?php if (!empty($row5['ch_landscape_type'])=="ghar")echo 'selected' ;?&gt;&gt;घर&lt;/option&gt;
           &lt;option value="land" &lt;?php if (!empty($row5['ch_landscape_type'])=="land")echo 'selected' ;?&gt;&gt;जग्गा&lt;/option&gt;
           &lt;option value="school" &lt;?php if (!empty($row5['ch_landscape_type'])=="school")echo 'selected' ;?&gt;&gt;स्कूल&lt;/option&gt;
           &lt;option value="temple" &lt;?php if (!empty($row5['ch_landscape_type'])=="temple")echo 'selected' ;?&gt;&gt;मन्दिर&lt;/option&gt;
           &lt;option value="party_palace" &lt;?php if (!empty($row5['ch_landscape_type'])=="party_palace")echo 'selected' ;?&gt;&gt;पार्टी प्यालेस&lt;/option&gt;
           &lt;option value="wall" &lt;?php if (!empty($row5['ch_landscape_type'])=="wall")echo 'selected' ;?&gt;&gt;पर्खाल &lt;/option&gt;
           &lt;option value="chowk" &lt;?php if (!empty($row5['ch_landscape_type'])=="chowk")echo 'selected' ;?&gt;&gt;चोक छ&lt;/option&gt;
           &lt;option value="pokhari" &lt;?php if (!empty($row5['ch_landscape_type'])=="pokhari")echo 'selected' ;?&gt;&gt;पोखरी&lt;/option&gt;
           &lt;option value="river" &lt;?php if (!empty($row5['ch_landscape_type'])=="river")echo 'selected' ;?&gt;&gt;नदि&lt;/option&gt;
           &lt;option value="rajkulo" &lt;?php if (!empty($row5['ch_landscape_type'])=="rajkulo")echo 'selected' ;?&gt;&gt;राजकुलो&lt;/option&gt;
           &lt;option value="public_land" &lt;?php if (!empty($row5['ch_landscape_type'])=="public_land")echo 'selected' ;?&gt;&gt;सार्वजनिक जग्गा&lt;/option&gt;
           &lt;option value="college" &lt;?php if (!empty($row5['ch_landscape_type'])=="college")echo 'selected' ;?&gt;&gt;कॉलेग&lt;/option&gt;
           &lt;option value="gumba" &lt;?php if (!empty($row5['ch_landscape_type'])=="gumba")echo 'selected' ;?&gt;&gt;गुम्बा&lt;/option&gt;
           &lt;option value="gl_road" &lt;?php if (!empty($row5['ch_landscape_type'])=="gl_road")echo 'selected' ;?&gt;&gt;जी एल रोड (बाटो नखुलेको)&lt;/option&gt;
           &lt;option value="well" &lt;?php if (!empty($row5['ch_landscape_type'])=="well")echo 'selected' ;?&gt;&gt;कुवा&lt;/option&gt;
    &lt;/select&gt;
  
  &lt;?php
       }
     }
  
  }
  ?&gt;
  
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/RBVya.jpg" rel="nofollow noreferrer">Page looks like this</a></p>