I am trying to save 2 photos to my MySQL database. I can only see one of the 2 photos in the database (i.e. its name) but I see the 2 photos in the folder I store my photos. ( A picture of how the database looks like is attached.) When I try to display the 2 photos, I only see that one photo that I saw in the database. What is the problem here?
Html Code to upload photo
<input type="file" id="_photo" name="_photo[]" multiple="multiple">
<input type="button" id="add_more" class="" value="Add More Files"/>
Code to save photos in database and folder
for ($i = 0; $i < count($_FILES["_photo"]["name"]); $i++) {
if (!empty($_FILES['_photo']['name'][$i])) {
if ($_FILES['_photo']['type'][$i] == 'image/jpeg') {
$upload_folder = "./profile_pix/";
$pic_name = time() . ".jpg";
$pic_path = $upload_folder . $pic_name;
require_once "include/resize.php";
if (move_uploaded_file($_FILES['_photo']['tmp_name'][$i], $pic_path)) {
$image = new Resize($pic_path);
$image->resizeImage(180, 180, 'crop');
$image->saveImage($pic_path);
//thumbnail
$image = new Resize($pic_path);
$image->resizeImage(50, 50, 'crop');
$image->saveImage($upload_folder . "thumb/" . $pic_name);
}
}
}
else {
$pic_name="default_house.png";
}
}
Code to display Uploaded Photos
$sql = "SELECT * FROM myDatabase";
foreach ($db->query($sql) AS $result){
echo "
<img src='profile_pix/{$result['photos']}' width = '30' height ='30px' style=' margin-top:8px;'/>
";
}