How can i get example code?

You will need to be a bit more specific. Can you give a few more details?

This is my code.I have position ,salary and employee register table .Now I want to display if I choose position ,automatic display salaryamount in text box.How can I do?

<?php
  include 'connect.php'; 
  $empname_pattern="/^[A-Z a-z]{3,30}$/";  
  $telephone_pattern="/^[0-9]{2,3}+[\-]+[0-9]{5,10}$/";
  $email_pattern="/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/";
  $empid_pattern="/^[0-9]{1,3}$/";

  if(!empty($_POST)){

  if(isset($_FILES['image'])){

     /*insert errors into array()*/
        $errors= array();   
        $file_name = $_FILES['image']['name'];  /*Image's Filename*/
        $file_size =$_FILES['image']['size'];   /*Image's Size*/
        $file_tmp =$_FILES['image']['tmp_name'];/*Image's temporary filename*/
        $file_type=$_FILES['image']['type'];    /*Image file type*/
        $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));/*Checking Image's extension */

        $expensions= array("jpeg","jpg","png","gif"); /*Image's Extension*/

        if(in_array($file_ext,$expensions)=== false){ 
            $errors['expension']="extension not allowed, please choose a JPEG or PNG file.";
        }
        if($file_size > 2097152){
        $errors['size']='File size must be exactely 2 MB';
        }               
      if($_POST["empname"]!=""){
    if(!preg_match($empname_pattern,$_POST['empname'])){     
       $errors['name_err']="* You must enter atleast three alphabetic";
       }
     }
  }
 if($_POST['empemail']!=""){
    if(!preg_match($email_pattern,$_POST["empemail"])){  
       $errors['email_err']=" * Invalid Email address";
   }
 }
   if($_POST['empphone']!=""){  
      if(!preg_match($telephone_pattern,$_POST['empphone'])){     
      $errors['telephone_err']="* Invalid telephone";
  }
  }
  if($_POST['empid']!=""){  
      if(!preg_match($empid_pattern,$_POST['empid'])){    
      $errors['empid_err']="* Only Digit";
  }
  }
  if(!$errors)
  {
     if(isset($_POST['empid'])&& isset($_POST['empphoto']) && isset($_POST['deptname']) && isset($_POST['position']) && isset($_POST['employeetypeid']) && isset($_POST['empname']) && isset($_POST['empbirth']) && isset($_POST['empphone']) && isset($_POST['empnrc']) && isset($_POST['empemail']) && isset($_POST['empgender'])  && isset($_POST['empmarital']) && isset($_POST['empaddress']) && isset($_POST['peraddress']) ){      
       $sql = "INSERT INTO empregister (empid,empphoto,deptid,empposition,emptype,empname,empbirth,empphone,empnrc,empemail,empgender,empmarital,address,permanentadd) VALUES ('$_POST[empid]','$_POST[empphoto]','$_POST[deptname]','$_POST[position]','$_POST[employeetypeid]','$_POST[empname]','$_POST[empbirth]','$_POST[empphone]','$_POST[empnrc]','$_POST[empemail]','$_POST[empgender]','$_POST[empmarital]','$_POST[empaddress]','$_POST[peraddress]')";
    if(!mysql_query($sql)){
    mysql_error();
 }
else
{
    header("Location:employeeView.php");
 }
}  
  }
  }
?>
<html>
      <head>
          <link href="css/bootstrap.css" type="text/css" rel="stylesheet">
          <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
          <link href="css/bootstrap-theme.css" type="text/css" rel="stylesheet">
          <link href="css/bootstrap-theme.min.css" type="text/css" rel="stylesheet">
        <!--  <link href="css/normalize.css" type="text/css" rel="stylesheet">-->
          <link href="css/employeeRecord.css" type="text/css" rel="stylesheet">
          <link rel="stylesheet" href="css/datepicker.css">
     </head>

       <div class="navbar navbar-inverse navbar-fixed-top ">     
          <div class="container-fluid">
              <div class="navbar-header">
                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                  </button>
                  <a class="navbar-brand" href="#">ExpressbusMM</a>
            </div>
            <div class="collapse navbar-collapse">
              <ul class="nav navbar-nav">
               <li><a href="department.php">DEPARTMENT</a></li>                                                 
               <li><a href="salary.php">SALARY</a></li>
               <li><a href="salaryView.php">SALARY VIEW</a></li>
               <li class="active"><a href="employeeRecord.php">EMPLOYEE REGISTER</a></li>
               <li><a href="employeeView.php">EMPLOYEE RECORD</a></li>
               <li><a href="leave.php">LEAVE</a></li>
               <li><a href="absence.php">ABSENCE</a></li>
             </ul>
           </div><!--/.nav-collapse -->
        </div><!--end container-->
      </div><!--end navbar-fixed-top-->
 <body style="background-color:DarkSlateGray;">
     <div class="container">
       <div class="wrapper">
            <div id="employeeform">     
          <div class="row">

           <form method="post" class="form-vertical" role="form">
            <fieldset style=" background-color:azure;">      

                  <legend class="col-xs-offset-5 col-xs-4 col-sm-offset-5 col-sm-4 col-md-offset-5 col-md-4 ">
                   <div id="employee">
                        Employee Registration Form
                  </div>  
                  </legend>

            <!--Employee Id-->         
               <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
                  <div class="form-group required">
                      <label for="empid" class="col-xs-12 col-sm-12 col-md-12 control-label">Employee ID:</label>
                  <div class="col-xs-12 col-sm-12 col-md-12">
                      <input class="form-control"  placeholder="Employee ID" type="text" required="required" name="empid"/>
                        <font color="red">
                           <?php if(isset($errors['empid_err'])) echo $errors['empid_err'];?>
                        </font>
                  </div>                  
                 </div>
              </div><br/><br/>

            <!--Employee Photo-->
                <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
                  <div class="form-group required">
                      <label for="empphoto" class="col-xs-12 col-sm-12 col-md-12 control-label">Employee Photo:</label>
                  <div class="col-xs-12 col-sm-12 col-md-12">
                      <input class="form-control"  placeholder="Employee ID" type="file" required="required" name="empphoto"/>
                           <font color="red">
                               <?php if(isset($errors['expension'])) echo $errors['expension'];?>
                           </font>   
                           <font color="red">
                               <?php if(isset($errors['size'])) echo $errors['size'];?>
                          </font>
                  </div>                  
                 </div>
              </div><br/><br/>

         <!--Department ID-->      
              <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
                  <div class="form-group required">
                      <label for="deptid" class="col-xs-12 col-sm-12 col-md-12 control-label">Department Name:</label>
                  <div class="col-xs-12 col-sm-12 col-md-12">
                      <?php
                          include 'connect.php';
                             $res = mysql_query("SELECT * FROM department ")  ;
                             // echo '<label>Select :</label>';
                                echo '<select id="category" name="deptname" class="form-control">';
                                echo '<option value="$id" selected="selected">Select</option>';
                                while ($row = mysql_fetch_assoc($res)) {
                                    $id=$row['deptid'];
                                  $name_value=$row['deptname'];                    
                                  echo "<option value='$id'>$name_value</option>";                    

                                       }
                                echo '</select>';                             
                          ?>
                        <font color="red">
                           <?php if(isset($errors['salaryid_err'])) echo $errors['salaryid_err'];?>
                        </font>
                  </div>                  
                 </div>
              </div><br/><br/>

            <!--Employee Position-->  
              <div class="col-xs-12 col-sm-offset-3 col-sm-6">
                  <div class="form-group required">
                      <label for="emppos" class="col-xs-12 col-sm-12 col-md-12 control-label">Position :</label>
                  <div class="col-xs-12 col-sm-12 col-md-12">
                      <?php
                          include 'connect.php';
                             $res = mysql_query("SELECT * FROM position")  or die("Invalid query: " . mysql_query);
                             // echo '<label>Select :</label>';
                                echo '<select id="category" name="position" class="form-control">';
                                echo '<option value="" selected="selected">Select</option>';
                                while ($row = mysql_fetch_assoc($res)) {
                                    $id=$row['posid'];
                                  $name_value=$row['posname'];                     
                                  echo "<option value='$name_value'>$name_value</option>";                

                                       }
                                echo '</select>';                             
                          ?>
                        <font color="red">
                           <?php if(isset($errors['salaryid_err'])) echo $errors['salaryid_err'];?>
                        </font>
                  </div>                  
                 </div>
              </div><br/><br/>  

            <!--Salary--> 
              <div class="col-xs-12 col-sm-offset-3 col-sm-6">
                  <div class="form-group required">
                      <label for="empid" class="col-xs-12 col-sm-12 col-md-12 control-label">Salary :</label>
                  <div class="col-xs-12 col-sm-12 col-md-12">

                        <font color="red">
                           <?php if(isset($errors['salaryid_err'])) echo $errors['salaryid_err'];?>
                        </font>
                  </div>                  
                 </div>
              </div><br/><br/>

              <!--Employee Type Id-->
                 <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
                  <div class="form-group required">
                      <label for="employeetypeid" class="col-xs-12 col-sm-12 col-md-12 control-label">Employee Type:</label>
                  <div class="col-xs-12 col-sm-12 col-md-12">
                      <select name="employeetypeid" class="form-control">
                         <option>probation employee</option>
                         <option>permanent employee</option>
                         <option>part time employee</option>
                         <option>Intership employee</option>
                         <option>Freelance employee</option>
                      </select>
                  </div>
                 </div>
              </div><br/><br/>

            <!--Employee Name-->  
             <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
               <div class="form-group required">               
                     <label for="empname" class="col-xs-12 col-sm-12 col-md-12 control-label">Employee Name:</label>
                 <div class="col-xs-12 col-sm-12 col-md-12">                    
                    <input class="form-control"  placeholder="Employee Name" type="text" name="empname" required="required"/>
                      <font color="red">
                         <?php if(isset($errors['name_err'])) echo $errors['name_err'];?>
                      </font>
                </div>               
              </div>           
            </div>

            <!--Employee Birth Date-->
           <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
             <div class="form-group required">
                   <label for="empbirth" class="col-xs-12 col-sm-12 col-md-12 control-label">Birthday:</label>
              <div class="col-xs-12 col-sm-12 col-md-12">              
               <input class="form-control"  placeholder="Choose Date " type="text" id="example1" name="empbirth" required="required"/>
              </div>
            </div>
          </div><br/>  

       <!--Employee Phone Number-->  
             <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
               <div class="form-group required">               
                     <label for="empphone" class="col-xs-12 col-sm-12 col-md-12 control-label">Phone Number:</label>
                 <div class="col-xs-12 col-sm-12 col-md-12">                    
                    <input class="form-control"  placeholder="Employee Phone Number" type="text" name="empphone" required="required"/>
                       <font color="red">
                         <?php if(isset($errors['telephone_err'])) echo $errors['telephone_err'];?>
                      </font>                        
                 </div>                                          
              </div>       
            </div>

            <!--Employee NRC Number-->  
             <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
               <div class="form-group required">               
                     <label for="empnrc" class="col-xs-12 col-sm-12 col-md-12 control-label">NRC Number:</label>
                 <div class="col-xs-12 col-sm-12 col-md-12">                    
                    <input class="form-control"  placeholder="Employee NRC Number" type="text" name="empnrc" required="required"/>
                      <font color="red">
                         <?php if(isset($errors['salaryamount_err'])) echo $errors['salaryamount_err'];?>
                      </font>
                </div>               
              </div>               
            </div>

            <!--Employee Email-->  
             <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
               <div class="form-group required">               
                     <label for="empemail" class="col-xs-12 col-sm-12 col-md-12 control-label">Email Address:</label>
                 <div class="col-xs-12 col-sm-12 col-md-12">                    
                    <input class="form-control"  placeholder="Employee Email Address" type="text" name="empemail" required="required"/>
                      <font color="red">
                         <?php if(isset($errors['email_err'])) echo $errors['email_err'];?>
                      </font>
                </div>               
              </div>               
            </div>

        <!--Employee Gender-->  
             <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
               <div class="form-group required">               
                     <label for="empgender" class="col-xs-12 col-sm-12 col-md-12 control-label">Gender:</label>
                 <div class="col-xs-12 col-sm-12 col-md-12">                    
                     <select name="empgender" class="form-control">
                         <option>Male</option>
                         <option>Female</option>                       
                     </select>
                </div>               
              </div>               
            </div>



            <!--Employee Marital-->  
             <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
               <div class="form-group required">               
                     <label for="empmarital" class="col-xs-12 col-sm-12 col-md-12 control-label">Marital:</label>
                 <div class="col-xs-12 col-sm-12 col-md-12">                    
                    <select name="empmarital" class="form-control">
                         <option>Single</option>
                         <option>Married</option>                      
                     </select>
                </div>               
              </div>               
            </div>

            <!--Employee Address-->  
             <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
               <div class="form-group required">               
                     <label for="empaddress" class="col-xs-12 col-sm-12 col-md-12 control-label">Employee Address:</label>
                 <div class="col-xs-12 col-sm-12 col-md-12">                    
                    <textarea class="form-control" rows="5" cols="40" name="empaddress" required="required" placeholder="Employee Address"/></textarea>                 
                </div>               
              </div>               
            </div>

            <!--Employee Permanent Address-->  
             <div class="col-xs-12 col-sm-offset-3 col-sm-6 ">
               <div class="form-group required">               
                     <label for="peraddress" class="col-xs-12 col-sm-12 col-md-12 control-label">Permanent Address:</label>
                 <div class="col-xs-12 col-sm-12 col-md-12">                    
                    <textarea class="form-control" rows="5" cols="40" name="peraddress" required="required" placeholder="Employee Permanent Address"/></textarea>                   
                </div>               
              </div>               
            </div>

       <!--Create Button-->     
            <div class="col-xs-offset-5 col-xs-7 col-sm-offset-5 col-sm-6 col-lg-offset-5 col-lg-4"> <br/>         
               <input class="btn btn-success" type="submit" value="Create"/>          
             </div>
          </fieldset>
        </form> 
      </div>  
   </div>        
 </div> 
        <!-- Load jQuery and  scripts -->
        <script src="js/jquery-1.9.1.min.js"></script>
        <script src="js/bootstrap-datepicker.js"></script>
        <!-- jQuery -->
       <script src="js/jquery.js"></script>

       <!-- Bootstrap Core JavaScript -->
       <script src="js/bootstrap.min.js"></script>

       <!-- Scrolling Nav JavaScript -->
       <script src="js/jquery.easing.min.js"></script>
       <script src="js/scrolling-nav.js"></script>

        <!--For Datetime picker-->
        <script type="text/javascript">           
            $(document).ready(function () {                
                $('#example1').datepicker({
                    format: "dd/mm/yyyy"
                }); 
             });
        </script>    
            </div>
       </div>
     </div>
</body>
</html>   
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.