Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Select Mange -til Mange; (Doesn't show up)
- <?php
- include('connect_mysql.php');
- $sql = "SELECT songname, artistname FROM song, artist, artist_has_song WHERE song.song_id=artist_has_song.song_song_id AND song.song_id = artist_has_song.song_song_id ORDER BY songname";
- $resultat = $kobling->query($sql);
- echo "<div class='tablediv'>";
- echo"<table>";
- echo "<tr>";
- echo"<th class='tabledesc'>Song Name</td>";
- echo"<th class='tabledesc'>Artist Name</td>";
- echo "</tr>";
- while($rad = $resultat->fetch_assoc()) {
- $songname = $rad["songname"];
- $artistname= $rad["artistname"];
- echo "<tr>";
- echo"<td class='tablerow'>$songname</td>";
- echo"<td class='tablerow'>$artistname</td>";
- echo "</tr>";
- }
- echo "</table>";
- echo "</div>";
- $conn->close();
- ?>
- Insert Mange -til Mange;
- <form method='POST'>
- <?php
- if(isset($_POST["leggtilbegge"])) {
- $song_id = $_POST["song_id"];
- $artist_id = $_POST["artist_id"];
- $sql ="INSERT INTO artist_has_song (song_id, artist_id) VALUES ('$song_id', '$artist_id')";
- if($conn->query($sql)) {
- echo "Completed";
- } else {
- echo "Blablalbablablablablablablabl $sql
- ($conn->error.";
- }
- }
- ?>
- Song Name
- <?php
- $sql = "SELECT * FROM song";
- $resultat = $conn->query($sql);
- echo "<select name='song_id'>";
- while ($rad = $resultat->fetch_assoc()) {
- $song_id = $rad["song_id"];
- $song_name = $rad["songname"];
- echo "<option value=$song_id>$songname</option>";
- }
- echo "</select>";
- ?>
- Artist Name
- <?php
- $sql = "SELECT * FROM artist";
- $resultat = $conn->query($sql);
- echo "<select name='artist_id'>";
- while ($rad = $resultat->fetch_assoc()) {
- $song_id = $rad["artist_id"];
- $song_name = $rad["artistname"];
- echo "<option value=$artist_id>$artistname</option>";
- }
- echo "</select>";
- ?>
- </form>
- <input type="submit" name="leggtilbegge" value ="Submit">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement