daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest May 16th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include "db.php";
  3.  
  4. function showAllData(){
  5.     global $connection;
  6.     $query = "SELECT * FROM users";
  7.     $result = mysqli_query($connection, $query);
  8.     if(!$result){
  9.         die('Query Failed' . mysqli_error());
  10.     }
  11.  
  12.   while($row = mysqli_fetch_assoc($result)){
  13.            
  14.           $id = $row['id'];
  15.            
  16.          echo  "<option value='$id'>$id</option>";
  17.        
  18.        }
  19. }
  20.  
  21. function UpdateTable(){
  22.  
  23.     global $connection;
  24.    $username = $_POST['username'];
  25.    $password = $_POST['password'];
  26.     $id = $_POST['id'];
  27. $query = "UPDATE users SET ";
  28. $query .= "username = '$username', ";
  29. $query .= "password = '$password' ";
  30. $query .= "WHERE id = $id ";
  31.     $result = mysqli_query($connection, $query);
  32.          if(!$result){
  33.              die("QUERY FAILED" . mysqli_error($connection));    
  34.          }
  35. }
  36.  
  37. function deleteRows(){
  38.  
  39.     global $connection;
  40.    $username = $_POST['username'];
  41.    $password = $_POST['password'];
  42.     $id = $_POST['id'];
  43.    
  44.     $query = "DELETE FROM users";
  45. $query .= "WHERE id = $id ";
  46.    
  47.     $result = mysqli_query($connection, $query);
  48.          if(!$result){
  49.              die("QUERY FAILED");    
  50.          }
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top