Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <?php
  2. $servername = "127.0.0.1";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "kontr";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12.  
  13. }
  14.  
  15. // sql to create table
  16. $sql = "CREATE TABLE IF NOT EXISTS books (
  17. isbn INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  18. title VARCHAR(30),
  19. published_year date,
  20. genre VARCHAR(50),
  21. author VARCHAR(50)
  22. )";
  23.  
  24. if ($conn->query($sql)) {
  25. //echo "Table books created successfully";
  26. } else {
  27. //echo "Error creating table: " . $conn->error;
  28. }
  29.  
  30. if(isset($_GET['add'])){
  31.  
  32. }
  33.  
  34. if(isset($_GET['search'])){
  35.  
  36. }
  37.  
  38. if(isset($_GET['change'])){
  39.  
  40. }
  41.  
  42. if(isset($_GET['sort'])){
  43.  
  44. }
  45.  
  46. $conn->close();
  47.  
  48. ?>
  49. <h2>Add book</h2>
  50. <form action="<?php echo $_SERVER['PHP_SELF']; ?>">
  51. <label for="t" >Title</label>
  52. <input id="t" type="text" name="title"></input>
  53. <label for="p" >Pulished Year</label>
  54. <input id="p" type="date" name="published_year"></input>
  55. <label for="g" >Genre</label>
  56. <input id="g" type="text" name="genre"></input>
  57. <label for="a" >Author</label>
  58. <input id="a" type="text" name="author"></input>
  59. <button type="submit" name="add">add</button>
  60. </form>
  61. <h2>Get book by Genre</h2>
  62. <form action="<?php echo $_SERVER['PHP_SELF']; ?>">
  63. <label for="gs">Genre</label>
  64. <input id="gs" type="text" name="genre"></input>
  65. <button type="submit" name="search">search</button>
  66. </form>
  67. <h2>Change book Title</h2>
  68. <form action="<?php echo $_SERVER['PHP_SELF']; ?>">
  69. <label for="i" >ISDN</label>
  70. <input id="i" type="number" name="isdn"></input>
  71. <label for="ti" >Title</label>
  72. <input id="ti" type="text" name="title"></input>
  73. <button type="submit" name="change">change</button>
  74. </form>
  75. <h2>Sort book by Author</h2>
  76. <form action="<?php echo $_SERVER['PHP_SELF']; ?>">
  77. <button type="submit" name="sort">sort</button>
  78. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement