Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $servername = "sampledb";
- $username = "samplename";
- $password = "password";
- $dbname = "dbname";
- $name=$_POST['name'];
- //echo $name;
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "CREATE TABLE Student_Records (fullname VARCHAR(30) NOT NULL, Student_ID INT (8) UNSIGNED, email VARCHAR (50), courses VARCHAR (300), grades VARCHAR(300));";
- $result = mysqli_query($conn, $sql);
- $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');";
- $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+');";
- $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+');";
- $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+');";
- $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+');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- $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');";
- if ($conn->multi_query($sql) === TRUE) {
- echo "New records created successfully";
- //echo $sql;
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn = new mysqli($servername, $username, $password, $dbname);
- $sql = "SELECT * from Student_Records where fullname = '$name'";
- //echo $sql;
- $result=$conn->query($sql);
- if ($result->num_rows > 0) {
- $query = "SELECT * FROM Student_Records"; //You don't need a ; like you do in SQL
- //$result1 = mysqli_query($conn,$query);
- $result1=$conn->query($query);
- echo "<br><br><table>"; // start a table tag in the HTML
- while($row = $result1->fetch_assoc()){ //Creates a loop to loop through results
- 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
- }
- echo "</table>"; //Close the table in HTML
- }
- else{
- echo "not found";
- }
- mysqli_close($conn);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement