0

i have a problem , i have to create a table called album and attach it with album files table with foreign key but i can't get the album id from the form because it's auto increment .is there any other option to put it except selecting last id from db to put it into the second table??

the code for album file table is

  if(move_uploaded_file($_FILES["files"]["tmp_name"][$key], $targetFilePath)){ 
                    // Image db insert sql 
                    $evid= "SELECT max(albumId) from p47_album";
                    $qq= mysqli_query($bis,$evid);
                    $ew = mysqli_num_rows($qq);
                    $ss=mysqli_fetch_row($qq); 
                    $albumId=$ss['0'];
                    $insertValuesSQL .= "('".$fileName."', NOW(),$albumId),"; 

then the insert sql code is

$insert = $bis->query("INSERT INTO p47_albumFile (file_name, uploade_on,albumId) VALUES $insertValuesSQL"); 
GMB
  • 216,147
  • 25
  • 84
  • 135

0 Answers0