Advertisement
musioks

PHP Code Snippets

Jun 14th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. $dbuser="root";
  4. $dbpass="";
  5. $dbhost="localhost";
  6. $dbname="salon";
  7.  
  8.   $conn=new PDO("mysql:host={$dbhost};dbname={$dbname}",$dbuser,$dbpass);
  9.  
  10.  ?>
  11.  
  12. /////////////////////////////////INSERT///////////////////////////////////////
  13. <?php
  14.  if(isset($_POST['submit'])){
  15.     $amount=$_POST['amount'];
  16.     $email=$data['email'];
  17.     $no=$data['staff_no'];
  18.     $username=$data['username'];
  19.     $q=$conn->prepare("INSERT INTO salary(staff_no,staff_name,staff_email,amount)VALUES(?,?,?,?)");
  20.     $q->bindParam(1,$no);
  21.     $q->bindParam(2,$username);
  22.     $q->bindParam(3,$email);
  23.     $q->bindParam(4,$amount);
  24.     $q->execute();
  25.     header("location:staff.php?paid");
  26.   }
  27. ?>
  28. /////////////////////////////////FETCH///////////////////////////////////////
  29. <?php
  30. $sql=$conn->prepare("SELECT * FROM bookings");
  31. $sql->execute();
  32. $fetch=$sql->fetchAll();
  33.  
  34. ?>
  35. <table>
  36. <thead>
  37.     <tr>
  38. <th>ID</th>
  39. <th>Name</th>
  40.     </tr>
  41.     </thead>
  42.     <tbody>
  43. <?php foreach($fetch as $nums){ ?>
  44.         <tr>
  45.             <td><?php echo $nums['id'];?></td>
  46.             <td><?php echo $nums['name'];?></td>
  47.         </tr>
  48. }
  49.     </tbody>
  50.  
  51. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement