daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Nov 21st, 2018 102 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "13081999";
  5.  
  6. // Create connection
  7. $conn = new mysqli($servername, $username, $password);
  8.  
  9. // Check connection
  10. if ($conn->connect_error) {
  11.     die("Connection failed: " . $conn->connect_error);
  12. }
  13. echo "Connected successfully";
  14. $sql = "CREATE DATABASE IF NOT EXISTS myDB";
  15. if($conn->query($sql)==TRUE){
  16.     echo DBsuccessfully;
  17. }else{
  18. echo erro; 
  19. }
  20.  
  21. $sql="CREATE TABLE  IF NOT EXISTS `mydb`.`film` ( `idfilm` INT(11) NOT NULL , `tenfilm` VARCHAR(45) NOT NULL , `idCategory` INT(11) NULL , `ngayphathanh` DATE NOT NULL , PRIMARY KEY (`idfilm`)) ENGINE = InnoDB ;";
  22. if($conn->query($sql)==TRUE){
  23.     echo DBsuccessfully;
  24. }else{
  25. echo $conn->error; 
  26. }
  27.  
  28. $sql = "CREATE TABLE IF NOT EXISTS `mydb`.`category` ( `IdCategory` INT NOT NULL , `ten` VARCHAR(11) NOT NULL , PRIMARY KEY (`IdCategory`)) ENGINE = InnoDB;";
  29. if($conn->query($sql)==TRUE){
  30.     echo DBsuccessfully;
  31. }else{
  32. echo $conn->error;
  33. }
  34. $sql = "CREATE TABLE if not exists `mydb`.`dienvien` ( `iddienvien` INT(11) NOT NULL , `ten` VARCHAR(45) NOT NULL , `ngaysinh` DATE NOT NULL , `gioitinh` VARCHAR(45) NOT NULL , PRIMARY KEY (`iddienvien`)) ENGINE = InnoDB;";
  35. if($conn->query($sql)==TRUE){
  36.     echo DBsuccessfully;
  37. }else{
  38.  
  39. echo $conn->error;
  40.  
  41. }
  42.  
  43.  
  44. $sql="CREATE TABLE If not exists`mydb`.`film_dienvien` ( `idfilm` INT NOT NULL , `iddienvien` INT NOT NULL , PRIMARY KEY (`idfilm`, `iddienvien`)) ENGINE = InnoDB";
  45.  
  46. if($conn->query($sql)==TRUE){
  47.     echo DBsuccessfully;
  48. }else{
  49.  
  50. echo $conn->error;
  51.  
  52.  
  53. }
  54. $sql="CREATE TABLE if not exists `mydb`.`khachhang` ( `idkhachhang` INT(11) NOT NULL , `ten` VARCHAR(45) NOT NULL , `ngaysinh` DATE NOT NULL , `gioitinh` VARCHAR(45) NOT NULL , PRIMARY KEY (`idkhachhang`)) ENGINE = InnoDB;";
  55. if($conn->query($sql)==TRUE){
  56.     echo DBsuccessfully;
  57. }else{
  58.  
  59. echo $conn->error;
  60. }
  61.  
  62. $sql = "Create table if not exists `mydb`.`tichket` (`idkhachhang` INT(11) NOT NULL,`idfilm` INT(11)NOT NULL ,`giave` INT(11) , `giochieu` TIMESTAMP(6) NOT NULL,PRIMARY KEY (`idfilm`, `idkhachhang`));";
  63.    
  64. if($conn->query($sql)==TRUE){
  65.     echo DBsuccessfully;
  66. }else{
  67.  
  68. echo $conn->error;
  69. }
  70. /*for($i=1;$i<=10;$i++){
  71. $sql ="insert into `mydb`.`film`  values ($i,\"film$i\",$i,2019/8/$i)";
  72.  
  73. if($conn->query($sql)==True){
  74.     echo $i;
  75. }else
  76.     echo $conn->error
  77. }
  78. }
  79. */
  80. for($i=1;$i<=10;$i++){
  81. $sql ="insert into `mydb`.`dienvien`  values ($i,\"diven$i\",$i,2019/8/$i),\" nu\"";
  82.  
  83. if($conn->query($sql)==True){
  84.     echo $i;
  85. }else
  86.     echo $conn->error
  87. }
  88. }
  89.  
  90.  
  91.  
  92.  
  93. ?>
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