The php of the image-fetching is in a standalone script, and linked in the img-tag, yes?
<img src="yourscript.php?pic_id="<?PHP echo $pic_id; ?>">
The method above won't work, because you can't do header() after echoing the img-data for the first picture. So the only way is to do the picture-data-treatment in a standalone script, and link it by img-tag.
As for linking the car-data with the picture-data:
You should create a field in the car-data table (int) and call it pic_id or something. This would then contain the picture_id, and will function as the link between the data and picture.
If you set it to default at 0, this may be used to lookup wether or not the car has a picture. If the car has a picture, just echo the img-tag, and the standalone picture-script will do the rest 😉
knutm