if(isset($_POST['Submit']))
{
$query="INSERT INTO `".$config['db']['pre']."projects` ( `project_id` ,
`project_description`,`project_name`,
`project_avatar`,
`project_in_work`
) VALUES ('',
'".validate_input($_POST['description'])."',
'".htmlspecialchars($_POST['name'],ENT_QUOTES)."',
'nofoto',
'".validate_input($_POST['in_work'])."'
);";
mysql_query($query) or die(mysql_error());
$project_id=mysql_insert_id();
/********************************************************************************
*********/
/************************** ATTACHMENTS ********************************************/
/********************************************************************************
*********/
foreach ($_FILES as $file) {
if ($file['name'] != "") {
if (!in_array($file['type'], $config['accepted_images'])) {
//do nothing
} else {
$attach_num = mysql_num_rows(mysql_query("SELECT 1 FROM `" . $config['db']['pre'] .
"images_projects`"));
$dir = floor($attach_num / 500) + 1;
$fname = upload_image($config, $file['tmp_name'], "../" . $config['folder_projects'] .
"/" . $dir . "/", "little|large|middle|middle3|micro");
mysql_query("INSERT INTO `" . $config['db']['pre'] .
"images_projects` (`file_id`, `object_id`, `file_name`) VALUES ('','" .
validate_input($project_id) . "','" . $dir . "/" . validate_input($fname) . "')") or
error(mysql_error());
//тут я втулил свой код, который сейчас добавляет только последнюю запись, что не есть приемлемо, т.к нужно все записи
foreach ($_POST['title'] as $post => $value ) {
if ($value != "") {
mysql_query("UPDATE `" . $config['db']['pre'] .
"images_projects` SET `image_description`= '" . $value . "' WHERE object_id = " . validate_input($project_id)) or
error(mysql_error());
}
}
// конец моего кода
mysql_query("UPDATE `" . $config['db']['pre'] .
"projects` SET `project_avatar`='" . $dir . "/" . validate_input($fname) .
"' WHERE `project_id`=" . validate_input($project_id)) or error(mysql_error());
}
}
}
mysql_query("UPDATE `" . $config['db']['pre'] .
"images_projects` SET `file_avatar`='1' WHERE `object_id`=" . validate_input($project_id) .
" LIMIT 1;") or error(mysql_error());
header('Location:project_view.php');
exit;
}
?>
.................................................... тут хтмл и немного ниже цыкл с фотками и описаниями к ним
<tr>
<td><strong>Изображения:</strong></td>
<td>
<?php for($i=1; $i< 11;$i++){ ?>
<strong>Описание:</strong><input type="text" name="title[<?php echo $i ?>]"><input name="uploadedfile<?php echo $i ?>" type="file" /><br>
<?php } ?>