I'm building an Audio playlist system. The system contains two separate databases.
Database 1: Records with with Artist - Title Database 2: Records with Artist - Title - file path
What I want: Check if Artist + Title from database 1 exists in database 2 and get the file path.
if EXISTS add to output and check next from database 1.
if NOT exists, skip and check next from database 1.
I made something like this, but I get more results then I expect.
<?php
include("config.php");
$query = $con->query("SELECT * FROM database1 WHERE scheduled = 0 ORDER BY added ASC");
foreach($query as $row) {
$artist= $row['artist'];
$title= $row['title'];
$query2 = $con->query("SELECT * FROM database2 WHERE artist = '$artist' AND title = '$title' AND active = 1");
while($data2 = $query2->fetch(PDO::FETCH_ASSOC)) {
$path = $data2['path'];
echo $path;
}
}
?>