Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "cs-sql2014.ua-net.ua.edu";
- $username = "etkeats";
- $password = "11494725";
- $conn = mysqli_connect($servername, $username, $password, 'etkeats');
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- echo "Connected successfully <br>";
- ?>
- <form method="post" action="index.php">
- Input: <input type="text" name="theInput" placeholder="student, teacher, course, textbook, department, or enrolled_in">
- <button type="submit">Submit </button>
- </form>
- <?php
- $sql = "select * from ".$_POST["theInput"];
- $result = mysqli_query($conn, $sql);
- ?>
- <table>
- <tr>
- <?php
- $headers = mysqli_fetch_fields($result);
- foreach($headers as $header) {
- echo "<th>" . $header->name . "</th>";
- }
- ?>
- </tr>
- <?php
- while($row = mysqli_fetch_assoc($result)) {
- echo "<tr>";
- foreach( $row as $col) {
- echo "<td>" . $col . "</td>";
- }
- echo "</tr>";
- }
- ?>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement