Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.38 KB | None | 0 0
  1. <?php
  2. include ("account.php") ;
  3. $name=$_POST['name'];
  4. $conn = new mysqli($hostname, $username, $password, $project);
  5.  
  6. // Check connection
  7. if ($conn->connect_error) {
  8. die("Connection failed: " . $conn->connect_error);
  9. }
  10. echo "Connected successfully<br>";
  11.  
  12. $sql = "DROP TABLE IF EXISTS `Student_Records`;";
  13.  
  14. if ($conn->query($sql) === TRUE) {
  15. echo "Table deleted successfully <br>";
  16. } else {
  17. echo "Error deleting table: <br>" . $conn->error;
  18. }
  19.  
  20. $sql = "CREATE TABLE Student_Records (fullname VARCHAR(30) NOT NULL, Student_ID INT (8) UNSIGNED, email VARCHAR (50), courses VARCHAR (300), grades VARCHAR(300));";
  21.  
  22. if ($conn->query($sql) === TRUE) {
  23. echo "Table created successfully <br>";
  24. } else {
  25. echo "Error creating table:<br>" . $conn->error;
  26. }
  27.  
  28. $sql = "INSERT INTO Student_Records VALUES('Pamela Diaz','20175051','pamela1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : A, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : A, Writing, Speaking, Thinking II: A, Calculus I : C, Physics II : C');";
  29. $sql .= "INSERT INTO Student_Records VALUES('Angela Anderson','20175052','angela1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B, Writing, Speaking, Thinking I: D, Calculus I : A, Physics I : A, Introduction to Computer Science I : A, Writing, Speaking, Thinking II: A, Calculus I : C, Physics II : C+');";
  30. $sql .= "INSERT INTO Student_Records VALUES('James Diaz','20175053','james1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science II : C, Writing, Speaking, Thinking II: C, Calculus I : C, Physics I : D, Introduction to Computer Science I : A, Writing, Speaking, Thinking II: A, Calculus I : C, Physics II : C+');";
  31. $sql .= "INSERT INTO Student_Records VALUES('Todd Diaz','20175054','todd1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : D, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : A, Writing, Speaking, Thinking II: A, Calculus I : C, Physics II : C+');";
  32. $sql .= "INSERT INTO Student_Records VALUES('Ted Diaz','20175055','ted1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : D, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : A, Writing, Speaking, Thinking II: A, Calculus I : C, Physics II : C+');";
  33. $sql .= "INSERT INTO Student_Records VALUES('Jane Diaz','20175056','jane1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  34. $sql .= "INSERT INTO Student_Records VALUES('Beth Diaz','20175057','beth1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : C, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : F, Writing, Speaking, Thinking II: F, Calculus I : C, Physics II : C');";
  35. $sql .= "INSERT INTO Student_Records VALUES('Johnathan Diaz','20175058','johnathan1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : F, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : F, Writing, Speaking, Thinking II: D, Calculus I : C, Physics II : C');";
  36. $sql .= "INSERT INTO Student_Records VALUES('Jason Diaz','20175059','jason1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : C, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : C, Writing, Speaking, Thinking II: C, Calculus I : C, Physics II : C');";
  37. $sql .= "INSERT INTO Student_Records VALUES('Jennifer Diaz','20175060','jennifer1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : C, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : C, Writing, Speaking, Thinking II: B, Calculus I : C, Physics II : C');";
  38. $sql .= "INSERT INTO Student_Records VALUES('Edgar Diaz','20175061','edgar1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B, Writing, Speaking, Thinking II: B, Calculus I : C, Physics II : C');";
  39. $sql .= "INSERT INTO Student_Records VALUES('Ana Diaz','20175062','ana1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : F, Writing, Speaking, Thinking II: F, Calculus I : C, Physics II : C');";
  40. $sql .= "INSERT INTO Student_Records VALUES('Anna Diaz','20175063','anna1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : F, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : D, Writing, Speaking, Thinking II: D, Calculus I : C, Physics II : C');";
  41. $sql .= "INSERT INTO Student_Records VALUES('Bobby Diaz','20175064','bobby1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : A, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : A, Writing, Speaking, Thinking II: A, Calculus I : C, Physics II : C');";
  42. $sql .= "INSERT INTO Student_Records VALUES('Bob Diaz','20175065','bob1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : A, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : A, Writing, Speaking, Thinking II: A, Calculus I : C, Physics II : C');";
  43. $sql .= "INSERT INTO Student_Records VALUES('Jeff Diaz','20175066','jeff1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : A, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : A, Writing, Speaking, Thinking II: A, Calculus I : C, Physics II : C');";
  44. $sql .= "INSERT INTO Student_Records VALUES('Eddy Diaz','20175067','eddy1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : A, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : A, Writing, Speaking, Thinking II: A, Calculus I : C, Physics II : C');";
  45. $sql .= "INSERT INTO Student_Records VALUES('Aly Diaz','20175068','aly1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : A, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : A, Writing, Speaking, Thinking II: A, Calculus I : C, Physics II : C');";
  46. $sql .= "INSERT INTO Student_Records VALUES('Renee Diaz','20175069','renee1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  47. $sql .= "INSERT INTO Student_Records VALUES('Evan Diaz','20175070','evan1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  48. $sql .= "INSERT INTO Student_Records VALUES('Kenny Diaz','20175071','kenny1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  49. $sql .= "INSERT INTO Student_Records VALUES('Matt Diaz','20175072','matt1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  50. $sql .= "INSERT INTO Student_Records VALUES('Nick Diaz','20175073','nick1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  51. $sql .= "INSERT INTO Student_Records VALUES('Seth Diaz','20175074','seth1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  52. $sql .= "INSERT INTO Student_Records VALUES('Charlotte Diaz','20175075','charlotte1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  53. $sql .= "INSERT INTO Student_Records VALUES('Sasha Diaz','20175076','sasha1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  54. $sql .= "INSERT INTO Student_Records VALUES('Becky Diaz','20175077','becky1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  55. $sql .= "INSERT INTO Student_Records VALUES('Dean Diaz ','20175078','dean1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  56. $sql .= "INSERT INTO Student_Records VALUES('Brock Diaz','20175079','brock1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  57. $sql .= "INSERT INTO Student_Records VALUES('Randy Diaz','20175080','randy1@gmail.com','Introduction to Computer Science I, Writing, Speaking, Thinking II, Calculus I, Physics I','Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B, Calculus I : C, Physics I : B+, Introduction to Computer Science I : B+, Writing, Speaking, Thinking II: B+, Calculus I : C, Physics II : C');";
  58.  
  59. if ($conn->multi_query($sql) === TRUE) {
  60. echo "New records created successfully<br>";
  61. //echo $sql;
  62. } else {
  63. echo "Error: " . $sql . "<br>" . $conn->error;
  64. }
  65.  
  66. $sql = "SELECT * from Student_Records where fullname = '$name'";
  67. //echo $sql;
  68. $result=$conn->query($sql);
  69. if ($result->num_rows > 0) {
  70. $query = "SELECT * FROM Student_Records"; //You don't need a ; like you do in SQL
  71. //$result1 = mysqli_query($conn,$query);
  72. $result1=$conn->query($query);
  73. echo "<br><br><table>"; // start a table tag in the HTML
  74. while($row = $result1->fetch_assoc()){ //Creates a loop to loop through results
  75. echo "<tr><td>" . $row['fullname'] . "</td><td>" . $row['Student_ID'] . "</td><td>" . $row['email'] . "</td><td>" . $row['courses'] . "</td><td>" . $row['grades'] . "</td></tr>"; //$row['index'] the index here is a field name
  76. }
  77.  
  78. echo "</table>"; //Close the table in HTML
  79. }
  80. else{
  81. echo "not found";
  82. }
  83.  
  84. $mysqli->close();
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement