Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
- <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
- <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
- <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
- <head>
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta charset="utf-8">
- <title>Internal</title>
- <style>
- html {
- background-image: url("WDF_2493417.jpg");
- background-size: 100% 100%;
- background-repeat: no-repeat;
- background-position: center;
- }
- html {
- margin: 0;
- padding: 0;
- height: 100%;
- }
- </style>
- </head>
- <body >
- <?php
- // php populate html table from mysql database
- $conn = mysqli_connect("localhost","root","");
- mysqli_select_db($conn, "my_db");
- $result = mysqli_query($conn,"SELECT * FROM ijob ORDER BY userId DESC");
- ?>
- <div class="form-style-1">
- <form name="frmUser" method="post" action="">
- <div style="width:1200px;">
- <table border="0" cellpadding="10" cellspacing="1" width="1200" class="tblListForm" align="center">
- <tr class="listheader">
- <td></td>
- <th>first name</th>
- <th>last name</th>
- <th></th>
- </tr>
- <?php
- $i=0;
- $j=1;
- while($row = mysqli_fetch_array($result)) {
- if($i%2==0){
- $classname="evenRow";
- } else {
- $classname="oddRow";
- }
- ?>
- <tr class="<?php if(isset($classname)) {
- echo $classname;
- }?>">
- <td><input type="checkbox" name="users" value="<?php echo $row["userId"]; ?>" ></td>
- <td><?php echo $row["fname"]; ?></td>
- <td><?php echo $row["lname"]; ?></td>
- <th colspan="4"><input type="button" name="update" class="button" value="Apply" onClick="checkAddress(this);" /></th></tr>
- <?php
- $i++;
- $j=$i+1;
- }
- $conn->close();
- ?>
- </table>
- </div>
- </form>
- </div>
- </body>
- <script>
- function checkAddress()
- {
- if (document.querySelector('form[name="frmUser"] input[type="checkbox"]:checked')) {
- if(!empty($_POST['users'])){
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "my_db";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $num_var= " ";
- $num_var = mysqli_real_escape_string($conn,$_POST['users']); // getting error on this Line.
- $query = "SELECT fname FROM ijob WHERE userId='$num_var'";
- $result = mysqli_query($conn,$query);
- if (!$result) {
- echo 'MySQL Error: ' . mysqli_error($conn);
- exit;
- }
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $fnames[] = $row['fname'];
- ?>
- alert("Hello <?php echo $fnames;?>");
- <?php
- }
- }
- $conn->close();
- ?>
- }
- document.frmUser.action = "form.php";
- document.frmUser.submit();
- } else {
- alert("Pl select checkbox which You wish to Apply ");
- }
- }
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement