Create a function that returns the artists by the artistid i.e
function convertArtists($id, $return_value) {
Select artists from ARTISTS where artistid = $id
read the artists and return its value
}
Compare the function returned value with the search value i.e
$search_value = convertArtists($id, 'artists');
I use this method all the time it works great.
i hope that helps.