Advertisement
Guest User

Untitled

a guest
May 24th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. Select Mange -til Mange; (Doesn't show up)
  2. <?php
  3. include('connect_mysql.php');
  4. $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";
  5. $resultat = $kobling->query($sql);
  6. echo "<div class='tablediv'>";
  7. echo"<table>";
  8. echo "<tr>";
  9. echo"<th class='tabledesc'>Song Name</td>";
  10. echo"<th class='tabledesc'>Artist Name</td>";
  11. echo "</tr>";
  12.  
  13. while($rad = $resultat->fetch_assoc()) {
  14. $songname = $rad["songname"];
  15. $artistname= $rad["artistname"];
  16. echo "<tr>";
  17. echo"<td class='tablerow'>$songname</td>";
  18. echo"<td class='tablerow'>$artistname</td>";
  19. echo "</tr>";
  20. }
  21. echo "</table>";
  22. echo "</div>";
  23. $conn->close();
  24. ?>
  25.  
  26.  
  27. Insert Mange -til Mange;
  28. <form method='POST'>
  29. <?php
  30. if(isset($_POST["leggtilbegge"])) {
  31. $song_id = $_POST["song_id"];
  32. $artist_id = $_POST["artist_id"];
  33.  
  34. $sql ="INSERT INTO artist_has_song (song_id, artist_id) VALUES ('$song_id', '$artist_id')";
  35.  
  36. if($conn->query($sql)) {
  37. echo "Completed";
  38.  
  39. } else {
  40. echo "Blablalbablablablablablablabl $sql
  41. ($conn->error.";
  42. }
  43. }
  44. ?>
  45.  
  46. Song Name
  47.  
  48. <?php
  49. $sql = "SELECT * FROM song";
  50. $resultat = $conn->query($sql);
  51.  
  52. echo "<select name='song_id'>";
  53.  
  54. while ($rad = $resultat->fetch_assoc()) {
  55. $song_id = $rad["song_id"];
  56. $song_name = $rad["songname"];
  57.  
  58. echo "<option value=$song_id>$songname</option>";
  59. }
  60.  
  61. echo "</select>";
  62. ?>
  63.  
  64. Artist Name
  65.  
  66. <?php
  67. $sql = "SELECT * FROM artist";
  68. $resultat = $conn->query($sql);
  69.  
  70. echo "<select name='artist_id'>";
  71.  
  72. while ($rad = $resultat->fetch_assoc()) {
  73. $song_id = $rad["artist_id"];
  74. $song_name = $rad["artistname"];
  75.  
  76. echo "<option value=$artist_id>$artistname</option>";
  77. }
  78.  
  79. echo "</select>";
  80. ?>
  81. </form>
  82. <input type="submit" name="leggtilbegge" value ="Submit">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement