Array which stores the paths/names of images:
$wall_filenames[]
Contents of $wall_filenames:
Array ( [0] => wallpapers/2014/03/calendar-thumbnail-520x264.jpg
[1] => wallpapers/2014/03/calendar-preview2-786x305.jpg )
MySQL Query:
$sql = "INSERT INTO walls(wall_name, wall_thumbnail_path, wall_preview1_path,
wall_preview2_path, wall_preview3_path,
upload_date, d_1280x800_path, d_1366x768_path, d_1920x1080_path,
p_640x960_path, p_640x1136_path, p_720x1280_path, p_768x1280_path,
p_1080x1920_path, t_1024x768_path, t_2048x1536_path)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$insert_wall = $connectDB->prepare($sql);
So the problem is, the table contains several columns. But when I insert once, it not necessary to upload all files which in my example above I'm only uploading two. What I need to do is add those array elements to there appropriate columns in my table. In this case I want $wall_filenames[0]
to be stored to wall_thumbnail_path
and $wall_filenames[1]
to wall_preview2_path
. I'm not sure how can I bind an array using bind_param()
to point to correct column in table.