Jump to content

johnjohny

New Members
  • Posts

    2
  • Joined

  • Last visited

johnjohny's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. @destramic , so how do I insert songID into my database I am new to php
  2. I have a table of albums and songs, if I want to add a song which is linked to my album the "songID" I have to insert it into my database, so I tried to add the id to my button " zie nummers (add-songs) " but it says I have a undefined index id I don't know how to fix this problem. : code of the table song : $db = mysqli_connect($host, $user, $pass,$database); if($db){ $h.= ""; $h.= "<form><table class='table table-striped table-hover'>"; $h.= "<tr>"; $h.= "<th>Nr.</th>"; $h.= "<th>Songs</th>"; $h.= "<td style='text-align:right;'><a href='/?action=add-songs&id='".$_GET['id']."' class='btn btn-primary'>VOEG TOE</a></td>"; $h.="<br>"; $h.= "</tr>"; $sql = mysqli_query($db,"SELECT * FROM songs WHERE songID = '".$_GET['id']."' "); if($sql){ if(mysqli_num_rows($sql)>0){ while ($row = mysqli_fetch_assoc($sql)){ $h.= "<tr>"; $h.= "<td>".$row['id']."</td>"; $h.= "<td>".$row['songName']."</td>"; $h.= "</tr>"; } }else{ echo "<tr>No Recore Found</tr>"; } $h.= "</table></form>"; echo $htop; echo $h; echo $hbot; code of add-songs : $db = mysqli_connect($host, $user, $pass,$database); if($_GET['action3'] == "2"){ mysqli_query($db, "INSERT INTO songs (songName, songID) VALUES ('".$_GET['songname']."')"); header("Location: /?action=show-songs"); } $h = ""; $h.= ""; $h.= "<form><input type='hidden' name='action' value='add-songs'><input type='hidden' name='action3' value='2'><input type='hidden' name='id' value='ids'><table class='table table-striped'>"; $h.= " <tr>"; $h.= " <td><b>Nummer</b></td>"; $h.= " <td><input type='text' name='songname' class='form-control' placeholder='Naam'></td>"; $h.= " </tr>"; $h.= " <tr>"; $h.= " <td colspan='2'><input class='btn btn-primary' type='submit' value='UPDATE'></td>"; $h.= " </tr>"; $h.= "</table></form>"; echo $htop; echo $h; echo $hbot;
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.