2017-11-05 7 views
0

エコー方式のラジオボタンをどうやってチェックできますか?このようなPHPのエコー内でラジオボタンをチェックしました

<?php 
     if(isset($_GET['sid'])){ 



      echo' 

    <div class="right_col" role="main">'; 
      $a=$_GET['sid']; 
      $update = $obj->selectdata($a); 

      foreach($update as $upd) 
      { 
       $upd['sname']; 
      echo' 
     <h1 class="text-center">update student</h1> 
     <div class="row"> 
      <div class="col-lg-6 col-md-6 col-sm-8"> 
       <form class="form-horizontal" action="dashboard.php?sid='.$upd['id'].'" method="POST" enctype="multipart/form-data"> 
        <div class="form-group"> 
         <label>Name</label> 
         <input type="text" value="'.$upd['sname'].'" name="sname" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Father Name</label> 
         <input type="text" value="'.$upd['sfname'].'" name="sfname" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Email</label> 
         <input type="email" value="'.$upd['email'].'" name="semail" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Password</label> 
         <input type="password" name="spass" placeholder="Change Password" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Date Of Birth</label> 
         <input type="date" value="'.$upd['dob'].'" name="sdob" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Gender</label> 

        <div class="radio-inline"> 

         <label><input type="radio" name="sgender" if($s_gender == Male){echo checked=checked} value="Male" />Male</label> 
        </div> 
        <div class="radio-inline"> 
        <label><input type="radio" name="sgender" if($s_gender == Female){echo checked=checked} value ="Female" />Female</label> 
        </div></div> 





        <div class="form-group"> 
         <label>Contact</label> 
         <input type="text" name="scontact" value="'.$upd['contact'].'" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Address</label> 
         <input type="text" name="saddress" value="'.$upd['address'].'" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Photo</label> 
         <input type="file" name="spic" required class="form-control"/> 
        </div> 
        <button type="submit" name="upt_form" class="btn btn-default">Submit</button> 
       </form> 
      </div> 
     </div>'; 


      } 
     } 
     else { 
     echo' 

    <div class="right_col" role="main"> 
      <h1 class="text-center">add student</h1> 
     <div class="row"> 
      <div class="col-lg-6 col-md-6 col-sm-8"> 
       <form class="form-horizontal" action="dashboard.php" method="POST" enctype="multipart/form-data"> 
        <div class="form-group"> 
         <label>Name</label> 
         <input type="text" name="sname" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Father Name</label> 
         <input type="text" name="sfname" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Email</label> 
         <input type="email" name="semail" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Password</label> 
         <input type="password" name="spass" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Date Of Birth</label> 
         <input type="date" name="sdob" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Gender</label> 

        <div class="radio-inline"> 
         <label><input type="radio" name="sgender" value="Male" required/>Male</label> 
        </div> 
        <div class="radio-inline"> 
        <label><input type="radio" name="sgender" value ="Female"required />Female</label> 
        </div></div> 
        <div class="form-group"> 
         <label>Contact</label> 
         <input type="text" name="scontact" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Address</label> 
         <input type="text" name="saddress" required class="form-control"/> 
        </div> 
        <div class="form-group"> 
         <label>Photo</label> 
         <input type="file" name="spic" required class="form-control"/> 
        </div> 
        <button type="submit" name="stu_form" class="btn btn-default">Submit</button> 
       </form> 
      </div> 
     </div>'; 
     } 
     ?> 

答えて

0

仕事:あなたは間違って使用した場合、他の適切な方法で自分の問題に

<input type="radio" '.($s_gender == Female ? 'checked="checked"' : "").' name="sgender" value ="Female" /> 
0
<?php 
    if(isset($_GET['sid'])){ 



     echo' 

<div class="right_col" role="main">'; 
     $a=$_GET['sid']; 
     $update = $obj->selectdata($a); 

     foreach($update as $upd) 
     { 
      $upd['sname']; 
     echo' 
    <h1 class="text-center">update student</h1> 
    <div class="row"> 
     <div class="col-lg-6 col-md-6 col-sm-8"> 
      <form class="form-horizontal" action="dashboard.php?sid='.$upd['id'].'" method="POST" enctype="multipart/form-data"> 
       <div class="form-group"> 
        <label>Name</label> 
        <input type="text" value="'.$upd['sname'].'" name="sname" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Father Name</label> 
        <input type="text" value="'.$upd['sfname'].'" name="sfname" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Email</label> 
        <input type="email" value="'.$upd['email'].'" name="semail" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Password</label> 
        <input type="password" name="spass" placeholder="Change Password" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Date Of Birth</label> 
        <input type="date" value="'.$upd['dob'].'" name="sdob" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Gender</label> 

       <div class="radio-inline"> 
if($upd['gender']== "Male") { 
echo ' 
        <label><input cheacked= "cheacked" type="radio" name="sgender" value="Male" />Male</label> 
</div>'; 
} 
else { 

    echo'    <div class="radio-inline"> 
       <label><input type="radio" cheacked= "cheacked" name="sgender" value ="Female" />Female</label> 
       </div></div>'; 
} 





       <div class="form-group"> 
        <label>Contact</label> 
        <input type="text" name="scontact" value="'.$upd['contact'].'" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Address</label> 
        <input type="text" name="saddress" value="'.$upd['address'].'" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Photo</label> 
        <input type="file" name="spic" required class="form-control"/> 
       </div> 
       <button type="submit" name="upt_form" class="btn btn-default">Submit</button> 
      </form> 
     </div> 
    </div>'; 


     } 
    } 
    else { 
    echo' 

<div class="right_col" role="main"> 
     <h1 class="text-center">add student</h1> 
    <div class="row"> 
     <div class="col-lg-6 col-md-6 col-sm-8"> 
      <form class="form-horizontal" action="dashboard.php" method="POST" enctype="multipart/form-data"> 
       <div class="form-group"> 
        <label>Name</label> 
        <input type="text" name="sname" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Father Name</label> 
        <input type="text" name="sfname" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Email</label> 
        <input type="email" name="semail" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Password</label> 
        <input type="password" name="spass" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Date Of Birth</label> 
        <input type="date" name="sdob" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Gender</label> 

       <div class="radio-inline"> 
        <label><input type="radio" name="sgender" value="Male" required/>Male</label> 
       </div> 
       <div class="radio-inline"> 
       <label><input type="radio" name="sgender" value ="Female"required />Female</label> 
       </div></div> 
       <div class="form-group"> 
        <label>Contact</label> 
        <input type="text" name="scontact" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Address</label> 
        <input type="text" name="saddress" required class="form-control"/> 
       </div> 
       <div class="form-group"> 
        <label>Photo</label> 
        <input type="file" name="spic" required class="form-control"/> 
       </div> 
       <button type="submit" name="stu_form" class="btn btn-default">Submit</button> 
      </form> 
     </div> 
    </div>'; 
    } 
    ?> 

使用は、このコードは、それはあなたの問題を解決した場合、私に知らせて、あなたが入れていましたジェンダー価値を得るための変数。