apl-mhd

Select Checkbox Live Saving

Sep 13th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.64 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Title</title>
  6.  
  7.     <link rel="stylesheet" href="css/style.css">
  8.  
  9.  
  10. </head>
  11. <body>
  12.  
  13.  
  14.     <div class="maindiv">
  15.  
  16.         <div class="leftselect">
  17.  
  18.             <form name="submit" action="job.php" method="get">
  19.  
  20.                 <input type="checkbox" name="job[]" value="IT_PROG"> I have a bike<br>
  21.                 <input type="checkbox" name="job[]" value="FI_ACCOUNT" > I have a car<br>
  22.                 <input type="checkbox" name="job[]" value="PU_CLERK"> I have a bike<br>
  23.                 <input type="checkbox" name="job[]" value="ST_MAN" > I have a car<br>
  24.  
  25.  
  26.                 <input type="submit" name="submit" value="Submit">
  27.  
  28.             </form>
  29.  
  30.  
  31.         </div>
  32.         <div class="maincontent">
  33.  
  34.         </div>
  35.  
  36.  
  37.     </div>
  38.  
  39. </body>
  40. </html>
  41.  
  42.  
  43. <!DOCTYPE html>
  44. <html lang="en">
  45. <head>
  46.     <meta charset="UTF-8">
  47.     <title>Title</title>
  48.  
  49.     <link rel="stylesheet" href="css/style.css">
  50.  
  51.  
  52. </head>
  53. <body>
  54.  
  55.  
  56.  
  57. <?php
  58. /**
  59.  * Created by PhpStorm.
  60.  * User: apelmahmud
  61.  * Date: 02/04/2017
  62.  * Time: 3:24 PM
  63.  */
  64.  
  65. //echo  $_GET['it'];
  66.  
  67. $serverName = 'localhost';
  68. $dbName = 'abc';
  69. $uName = 'root';
  70. $pass = '';
  71.  
  72. /*$itProg = $_GET['it'];
  73.  
  74. echo  $itProg."</br>";*/
  75.  
  76.  
  77. /*
  78. for ($_GET['job'] as $key->$val){
  79.  
  80.     //echo
  81. }*/
  82.  
  83. $jobArray =  $_GET['job']; /*Select checkbox */
  84.  
  85.  
  86. foreach ($jobArray as  $key => $val) /* array convert*/
  87.     $arr2[$key] = $val;
  88.  
  89.  
  90.  
  91. $in = join("','", $arr2); //join array
  92.  
  93. //echo $in."<br>";
  94.  
  95.  
  96. $con =  new  mysqli($serverName,$uName,$pass,$dbName);
  97.  
  98. if($con->connect_error)
  99.     die("connect fail".$con->connect_error);
  100.  
  101.  
  102. $sql  = "SELECT * FROM employees where  job_id in('$in')";
  103.  
  104. $result = $con->query($sql);
  105.  
  106.  
  107. print_r( $result->fetch_assoc());
  108. echo "<br>";
  109. print_r( $result->fetch_assoc());
  110.  
  111.  
  112. echo  $result->num_rows;
  113.  
  114. echo "<table border='1px solid gray'>
  115.  
  116.        <tr>
  117.        <th> Employees_id </th>
  118.        <th>First Name </th>
  119.        <th>Email </th>
  120.        <th>Phone Number </th>
  121.        <th>Job ID </th>
  122.        <th>Salary </th>
  123.        <th>Manager ID </th>
  124.        <th>Department ID </th>
  125. </tr>";
  126.  
  127. while ($row = $result->fetch_assoc()){
  128.  
  129.  
  130.     echo "<tr>
  131.  
  132.      <td>".$row['EMPLOYEE_ID']."</td>
  133.      <td>".$row['FIRST_NAME']."</td>
  134.      <td>".$row['EMAIL']."</td>
  135.      <td>".$row['PHONE_NUMBER']."</td>
  136.      <td>".$row['JOB_ID']."</td>
  137.      <td>".$row['SALARY']."</td>
  138.      <td>".$row['MANAGER_ID']."</td>
  139.      <td>".$row['DEPARTMENT_ID']."</td>
  140.      
  141.  
  142.    </tr>";
  143. }
  144.  
  145.  
  146. echo "</table>";
  147.  
  148.  
  149.  
  150.  
  151.  
  152. $con->close();
  153.  
  154.  
  155. ?>
  156.  
  157. </body>
  158. </html>
Add Comment
Please, Sign In to add comment