Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- </head>
- <body>
- <form action="insertData.php" method="post">
- artist: <input type="varchar" name="artist" method="post"><br>
- title: <input type="varchar" name="title"method="post"><br>
- category: <input type="varchar" name="category"method="post"><br>
- played: <input type="int" name="played"method="post"><br>
- tracks: <input type="int" name="tracks"method="post"><br>
- reldate: <input type="date" name="reldate"method="post"><br>
- <input type="submit" value="Insert">
- </form>
- <form action="deleteData.php" method="post">
- id: <input type="int" name="id"><br>
- <input type="submit" value="Delete">
- </form>
- <form action="updateData.php" method="post">
- id: <input type="int" name="id"><br>
- artist: <input type="varchar" name="artist" ><br>
- title: <input type="varchar" name="title"><br>
- category: <input type="varchar" name="category"><br>
- played: <input type="int" name="played"><br>
- tracks: <input type="int" name="tracks"><br>
- reldate: <input type="date" name="reldate"><br>
- <input type="submit" value="Update">
- </form>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "cs230";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "SELECT artist,id ,title, category, played, tracks, reldate FROM cdset";
- $result = $conn->query($sql);
- echo '<table border=1 cellpadding=1 width ="90%">';
- echo "<td style='border:1px solid black;Font-size:18;Font-Weight:bold;text-align:center'>";
- echo "artist";
- echo "</td>";
- echo "<td style='border:1px solid black;Font-size:18;Font-Weight:bold;text-align:center'>";
- echo "id";
- echo "</td>";
- echo "<td style='border:1px solid black;Font-size:18;Font-Weight:bold;text-align:center'>";
- echo "title";
- echo "</td>";
- echo "<td style='border:1px solid black;Font-size:18;Font-Weight:bold;text-align:center'>";
- echo "category";
- echo "<td style='border:1px solid black;Font-size:18;Font-Weight:bold;text-align:center'>";
- echo "played";
- echo "<td style='border:1px solid black;Font-size:18;Font-Weight:bold;text-align:center'>";
- echo "tracks";
- echo "<td style='border:1px solid black;Font-size:18;Font-Weight:bold;text-align:center'>";
- echo "reldate";
- echo "</td>";
- if($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo '<tr class = "t_row">';
- echo '<td>' .$row['artist']. '</td>';
- echo '<td>' .$row['id']. '</td>';
- echo '<td>' .$row['title']. '</td>';
- echo '<td>' .$row['category']. '</td>';
- echo '<td>' .$row['played']. '</td>';
- echo '<td>' .$row['tracks']. '</td>';
- echo '<td>' .$row['reldate']. '</td>';
- }
- echo '</table>';
- }else {
- echo "0 results";
- }
- $conn->close();
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment