Advertisement
Guest User

Untitled

a guest
Mar 17th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
  3. <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
  4. <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
  5. <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
  6. <head>
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  8. <meta charset="utf-8">
  9. <title>Internal</title>
  10.  
  11. <style>
  12. html {
  13. background-image: url("WDF_2493417.jpg");
  14. background-size: 100% 100%;
  15. background-repeat: no-repeat;
  16. background-position: center;
  17. }
  18.  
  19. html {
  20. margin: 0;
  21. padding: 0;
  22. height: 100%;
  23. }
  24. </style>
  25.  
  26. </head>
  27.  
  28. <body >
  29.  
  30. <?php
  31.  
  32. // php populate html table from mysql database
  33.  
  34. $conn = mysqli_connect("localhost","root","");
  35. mysqli_select_db($conn, "my_db");
  36. $result = mysqli_query($conn,"SELECT * FROM ijob ORDER BY userId DESC");
  37. ?>
  38.  
  39. <div class="form-style-1">
  40. <form name="frmUser" method="post" action="">
  41. <div style="width:1200px;">
  42. <table border="0" cellpadding="10" cellspacing="1" width="1200" class="tblListForm" align="center">
  43. <tr class="listheader">
  44. <td></td>
  45. <th>first name</th>
  46. <th>last name</th>
  47. <th></th>
  48. </tr>
  49. <?php
  50. $i=0;
  51. $j=1;
  52. while($row = mysqli_fetch_array($result)) {
  53. if($i%2==0){
  54. $classname="evenRow";
  55. } else {
  56. $classname="oddRow";
  57. }
  58. ?>
  59. <tr class="<?php if(isset($classname)) {
  60. echo $classname;
  61. }?>">
  62. <td><input type="checkbox" name="users" value="<?php echo $row["userId"]; ?>" ></td>
  63. <td><?php echo $row["fname"]; ?></td>
  64. <td><?php echo $row["lname"]; ?></td>
  65. <th colspan="4"><input type="button" name="update" class="button" value="Apply" onClick="checkAddress(this);" /></th></tr>
  66. <?php
  67. $i++;
  68. $j=$i+1;
  69. }
  70. $conn->close();
  71. ?>
  72. </table>
  73. </div>
  74. </form>
  75.  
  76. </div>
  77.  
  78. </body>
  79. <script>
  80. function checkAddress()
  81. {
  82. if (document.querySelector('form[name="frmUser"] input[type="checkbox"]:checked')) {
  83.  
  84. if(!empty($_POST['users'])){
  85. <?php
  86. $servername = "localhost";
  87. $username = "root";
  88. $password = "";
  89. $dbname = "my_db";
  90.  
  91. // Create connection
  92. $conn = new mysqli($servername, $username, $password, $dbname);
  93. // Check connection
  94. if ($conn->connect_error) {
  95. die("Connection failed: " . $conn->connect_error);
  96. }
  97. $num_var= " ";
  98. $num_var = mysqli_real_escape_string($conn,$_POST['users']); // getting error on this Line.
  99.  
  100. $query = "SELECT fname FROM ijob WHERE userId='$num_var'";
  101. $result = mysqli_query($conn,$query);
  102. if (!$result) {
  103. echo 'MySQL Error: ' . mysqli_error($conn);
  104. exit;
  105. }
  106.  
  107. if ($result->num_rows > 0) {
  108. // output data of each row
  109. while($row = $result->fetch_assoc()) {
  110. $fnames[] = $row['fname'];
  111. ?>
  112. alert("Hello <?php echo $fnames;?>");
  113.  
  114. <?php
  115. }
  116.  
  117. }
  118. $conn->close();
  119.  
  120. ?>
  121. }
  122. document.frmUser.action = "form.php";
  123. document.frmUser.submit();
  124. } else {
  125. alert("Pl select checkbox which You wish to Apply ");
  126. }
  127. }
  128. </script>
  129.  
  130. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement