title: check a radio button based on value retrieved from database
body: <p>I have radio buttons that want to check if value retrieved from database is 'Yes'.
  on this same forum a same question is there but after trying that and still no success. also i can't comment there anything about my question because i don't have sufficient reputation.
  link to the question same as mine is:
  <a href="https://stackoverflow.com/questions/6197377/how-to-set-the-value-for-radio-buttons-when-edit">How to set the value for Radio Buttons When edit?</a></p>
  
  <p>Below is the Form code which displays fetched data:</p>
  
  <pre><code>&lt;?php
  error_reporting(0);
  $server="localhost";
  $user="root";
  $password="";
  $database="camouflage_studio";
  
  $con = mysqli_connect($server,$user,$password,$database);
  if (mysqli_connect_errno())
    {
    echo "Connection Error: " . mysqli_connect_error();
    }
  //receiving CINC from search form and getting record on it's basis
  $cnic = $_POST['search'];
  $data = "SELECT * FROM personal_detail WHERE CNIC='$cnic'";
  if($query = mysqli_query($con, $data)){
        $data2 = mysqli_fetch_array($query);  //i think it's used for to know the total number of rows fetched/retrieved 
  }else{ echo "Query Not Executed!";}
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Camouflage Studio - Welcome&lt;/title&gt;
  &lt;!-- My CSS coding starts here --&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;!-- form to display Retrieved/Fetched data--&gt;
  &lt;center&gt;
  &lt;form action="update.php" method="post"&gt;
  &lt;fieldset style="width:50%"&gt;&lt;legend&gt;Please do the required changes&lt;/legend&gt;&lt;br&gt;
  &lt;label for="Name"&gt;Name :&lt;br&gt;&lt;/label&gt;&lt;input name="name" type="text" size="20" maxlength="40" value="&lt;?php echo $data2[Name]?&gt;"&gt;&lt;br&gt;
  &lt;label for="CNIC"&gt;CNIC :&lt;br&gt;&lt;/label&gt;&lt;input name="cnic" type="text" size="20" maxlength="15" value="&lt;?php echo $data2[CNIC]?&gt;"&gt;&lt;br&gt;
  &lt;label for="Date"&gt;Booking Date :&lt;br&gt;&lt;/label&gt;&lt;input name="booking-date" type="date" size="20" value="&lt;?php echo $data2[Date]?&gt;"&gt;&lt;br&gt;
  
  &lt;!-- &lt;label for="Ocassion"&gt;Ocassion :&lt;br&gt;&lt;/label&gt; --&gt;
  &lt;label for="Ocassion"&gt;Ocassion :&lt;br&gt;&lt;/label&gt;&lt;input name="ocassion" type="text" size="20" maxlength="15" value="&lt;?php echo $data2[Ocassion]?&gt;"&gt;&lt;br&gt;
  
  &lt;label for="Address"&gt;Address :&lt;br&gt;&lt;/label&gt;&lt;input name="address" type="text" size="20" maxlength="11" value="&lt;?php echo $data2[Address]?&gt;"&gt;&lt;br&gt;
  
  &lt;label for="Phone Number"&gt;Phone Number :&lt;br&gt;&lt;/label&gt;&lt;input name="phone-no" type="text" size="20" maxlength="11" value="&lt;?php echo $data2[Phone_No]?&gt;"&gt;&lt;br&gt;
  &lt;label for="Bride Mobile"&gt;Bride Mobile :&lt;br&gt;&lt;/label&gt;&lt;input name="bride-mobile" type="number" size="20" maxlength="11" value="&lt;?php echo $data2[Bride_Mobile]?&gt;"&gt;&lt;br&gt;
  &lt;label for="Groom Mobile"&gt;Groom Mobile :&lt;br&gt;&lt;/label&gt;&lt;input name="groom-mobile" type="number" size="20" maxlength="11" value="&lt;?php echo $data2[Groom_Mobile]?&gt;"&gt;&lt;br&gt;
  &lt;label for="Family Mobile"&gt;Family Mobile :&lt;br&gt;&lt;/label&gt;&lt;input name="family-mobile" type="number" size="20" maxlength="11" value="&lt;?php echo $data2[Family_Mobile]?&gt;"&gt;&lt;br&gt;
  &lt;label for="Email"&gt;Email :&lt;br&gt;&lt;/label&gt;&lt;input name="email" type="text" size="20" maxlength="30" value="&lt;?php echo $data2[EMail]?&gt;"&gt;&lt;br&gt;
  &lt;label for="Who may I Thank for Refering You?"&gt;Who may I Thank for Refering You? :&lt;br&gt;&lt;/label&gt;&lt;input name="refering" type="text" size="20" maxlength="40" value="&lt;?php echo $data2[Referring]?&gt;"&gt;&lt;br&gt;
  &lt;label for="Do you provide consent to share images on our official web page"&gt;Do you provide consent to share images on our official web page? :&lt;br&gt;&lt;br&gt;&lt;/label&gt;&lt;input type="radio" name="share" &lt;?php echo ($data2[Share]=='Yes')?'checked':'' ?&gt; value="Yes"&gt;Yes&lt;br&gt;
  &lt;input type="radio" name="share" &lt;?php echo ($data2[Share]=='Yes')?'checked':'' ?&gt; value="No"&gt;No&lt;br&gt;&lt;br&gt;
  &lt;label for="If yes, with Identity"&gt;If yes, with Identity? :&lt;br&gt;&lt;br&gt;&lt;/label&gt;&lt;input type="radio" name="permission" &lt;?php echo ($data2[Permission]=='Yes')?'checked':'' ?&gt; value="Yes"&gt;Yes&lt;br&gt;
  &lt;input type="radio" name="permission" &lt;?php echo ($data2[Permission]=='Yes')?'checked':'' ?&gt; value="No"&gt;No&lt;br&gt;&lt;br&gt;
  &lt;!-- To center the button i'm embedding the buttons in a paragraph with an id as well. the id is used for CSS in head --&gt;
  &lt;p id="btn"&gt;
  &lt;input type="submit" value="Update Record" name="submit_display_data_form" style="font-size:16px"&gt;&lt;/p&gt;
  &lt;/fieldset&gt;
  &lt;/form&gt;
  &lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>