Last active
September 3, 2024 07:08
-
-
Save quickgrid/35d3bcc75724aca3f889153c3ef7afff to your computer and use it in GitHub Desktop.
Revisions
-
quickgrid revised this gist
Oct 19, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ <?php //Change the password to match your configuration $link = mysqli_connect("localhost", "root", "yourPassword", "cse"); // Check connection -
quickgrid revised this gist
Oct 19, 2016 . 1 changed file with 6 additions and 35 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,8 +10,6 @@ </head> <body> <?php // @@ -26,29 +24,21 @@ $sql = "SELECT id, name, salary FROM instructor"; $result = $link->query($sql); echo "<div class='container'>"; echo "<div class='row-fluid'>"; echo "<div class='col-xs-6'>"; echo "<div class='table-responsive'>"; echo "<table class='table table-hover table-inverse'>"; echo "<tr>"; echo "<th>ID</th>"; echo "<th>Name</th>"; echo "<th>Salary</th>"; echo "</tr>"; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { @@ -63,7 +53,6 @@ echo "0 results"; } echo "</table>"; @@ -79,8 +68,6 @@ echo "<th>year</th>"; echo "</tr>"; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { @@ -99,9 +86,6 @@ echo "</div>"; echo "</div>"; /* * second table */ @@ -119,9 +103,7 @@ echo "<th>Department</th>"; echo "<th>credits</th>"; echo "</tr>"; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { @@ -148,8 +130,7 @@ /* * second row */ $sql = "SELECT building, room_number, time_slot_id FROM section"; $result = $link->query($sql); @@ -165,9 +146,7 @@ echo "<th>room_number</th>"; echo "<th>time_slot_id</th>"; echo "</tr>"; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { @@ -187,8 +166,6 @@ echo "</div>"; echo "</div>"; /* * second table @@ -207,8 +184,6 @@ echo "<th>Prerequite ID</th>"; echo "</tr>"; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { @@ -227,14 +202,10 @@ echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>"; // Close connection mysqli_close($link); ?> -
quickgrid created this gist
Oct 19, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,244 @@ <!DOCTYPE html> <html lang="en"> <head> <title>Sample PHP Database Application</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"></script> </head> <body> <?php // $link = mysqli_connect("localhost", "root", "yourPassword", "cse"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } echo "<br>"; $sql = "SELECT id, name, salary FROM instructor"; $result = $link->query($sql); echo "<div class='container'>"; echo "<div class='row-fluid'>"; echo "<div class='col-xs-6'>"; echo "<div class='table-responsive'>"; echo "<table class='table table-hover table-inverse'>"; echo "<tr>"; echo "<th>ID</th>"; echo "<th>Name</th>"; echo "<th>Salary</th>"; echo "</tr>"; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td>" . $row["id"] . "</td>"; echo "<td>" . $row["name"] . "</td>"; echo "<td>" . $row["salary"] . "</td>"; echo "</tr>"; } } else { echo "0 results"; } echo "</table>"; $sql = "SELECT semester, year FROM section"; $result = $link->query($sql); echo "<table class='table table-hover table-inverse'>"; echo "<tr>"; echo "<th>semester</th>"; echo "<th>year</th>"; echo "</tr>"; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td>" . $row["semester"] . "</td>"; echo "<td>" . $row["year"] . "</td>"; echo "</tr>"; } } else { echo "0 results"; } echo "</table>"; echo "</div>"; echo "</div>"; /* * second table */ $sql = "SELECT course_id, title, dept_name, credits FROM course"; $result = $link->query($sql); echo "<div class='col-xs-6'>"; echo "<div class='table-responsive'>"; echo "<table class='table table-hover table-inverse'>"; echo "<tr>"; echo "<th>Course ID</th>"; echo "<th>Title</th>"; echo "<th>Department</th>"; echo "<th>credits</th>"; echo "</tr>"; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td>" . $row["course_id"] . "</td>"; echo "<td>" . $row["title"] . "</td>"; echo "<td>" . $row["dept_name"] . "</td>"; echo "<td>" . $row["credits"] . "</td>"; echo "</tr>"; } } else { echo "0 results"; } echo "</table>"; echo "</div>"; echo "</div>"; echo "</div>"; /* * second row */ $sql = "SELECT building, room_number, time_slot_id FROM section"; $result = $link->query($sql); echo "<div class='row-fluid'>"; echo "<div class='col-xs-6'>"; echo "<div class='table-responsive'>"; echo "<table class='table table-hover table-inverse'>"; echo "<tr>"; echo "<th>building</th>"; echo "<th>room_number</th>"; echo "<th>time_slot_id</th>"; echo "</tr>"; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td>" . $row["building"] . "</td>"; echo "<td>" . $row["room_number"] . "</td>"; echo "<td>" . $row["time_slot_id"] . "</td>"; echo "</tr>"; } } else { echo "0 results"; } echo "</table>"; echo "</div>"; echo "</div>"; /* * second table */ $sql = "SELECT course_id, prereq_id FROM prereq"; $result = $link->query($sql); echo "<div class='col-xs-6'>"; echo "<div class='table-responsive'>"; echo "<table class='table table-hover table-inverse'>"; echo "<tr>"; echo "<th>Course ID</th>"; echo "<th>Prerequite ID</th>"; echo "</tr>"; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td>" . $row["course_id"] . "</td>"; echo "<td>" . $row["prereq_id"] . "</td>"; echo "</tr>"; } } else { echo "0 results"; } echo "</table>"; echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>"; // Close connection mysqli_close($link); ?> </body> </html>