Advertisement
Guest User

Untitled

a guest
Jul 31st, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Suspects DB</title>
  5.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  6.     <link rel="stylesheet" type="text/css" href="style.css">
  7.     <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
  8.     <!-- font awesome for the external icon -->
  9.     <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
  10.  
  11.  
  12.     <script>
  13.     function openWin(id)
  14.         {   //with the ,"", we open a new popup window
  15.  
  16.             // var newWindow = window.open("\img/"+id+".jpg" ,"", "width=300,heigth=400");
  17.  
  18.             //troubleshooting
  19.             console.log(id + ".jpg");
  20.            
  21.             //newId = parseInt(id) //no need, POST sends string anyway
  22.  
  23.             // POST to update.php for the myslq query
  24.             $.ajax({
  25.                 url: "update.php",
  26.                 data: {id : id},
  27.                 // processData: false,
  28.                 // contentType: false,
  29.                 type: "POST",
  30.                
  31.                
  32.  
  33.                 success: function(data){console.log("reply: " + data)}
  34.            
  35.  
  36.             }
  37.             );
  38.         }
  39.  
  40.  
  41. </script>
  42.  
  43. </head>
  44. <body>
  45. <!-- jquery & JS -->
  46. <script src="https://code.jquery.com/jquery-2.2.4.js"></script>
  47.  
  48.  
  49. todo:<br>
  50. To develop and implement a functionality for adding/updating/deleting NUMBER elements in the table. <br>
  51.  
  52.  
  53. </body>
  54. </html>
  55.  
  56. <?php
  57. $servername = "localhost";
  58. $username = "root";
  59. $password = "secret";
  60. $dbname = "test";
  61.  
  62. // Create connection
  63. $conn = new mysqli($servername, $username, $password, $dbname);
  64.  
  65. // Check connection
  66. if ($conn->connect_error) {
  67.     die("Connection failed: " . $conn->connect_error);
  68. }
  69. //echo "Connected successfully";
  70. $selectAll = "SELECT * FROM suspects";
  71. $result = $conn->query($selectAll);
  72.  
  73. if ($result->num_rows > 0) {
  74.             // // prepare the table headers
  75.     echo "<div class=\"container\">";
  76.             echo "<table>
  77.                 <tr>
  78.                     <th>Name</th>
  79.                     <th>Image</th>
  80.                     <th>Count</th>
  81.                 </tr>";
  82.     //output data on each row
  83.  
  84.     while ($row = $result->fetch_assoc()) {
  85.         //variables for easier access
  86.         $name = $row["name"];
  87.         $id = $row["id"];
  88.  
  89.         //output data for each row
  90.         echo "<tr><td>"."$name"."</td><td>".
  91.              "<button onclick=\"openWin($id)\">
  92.              <i class=\"fa fa-external-link fa-lg\" aria-hidden=\"true\"></i>
  93.              <a class=\"thumb\" href=img/$id.jpg></a></button>".
  94.              "</td><td class = \"id\" >".$row["count"]."</td></tr>";    
  95.     }
  96.     echo "</table>";
  97.     echo "</div>";
  98. }
  99. $conn->close();
  100.  
  101. //echo "Connection closed!"
  102.  
  103. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement