Code:
<html>
<body>
<?php require (\'config.php\'); // data to connect to the DB ?>
<?php
echo \"<form name=\\\"image_upload\\\" enctype=\\\"multipart/form-data\\\" method=\\\"post\\\" action=\\\"$PHP_SELF\\\">\\n\";
$fields = 4; // number of upload fields
for($x=0;$x<$fields;$x++){ // start of dynamic form (loop)
echo \"<input name=\\\"image$x\\\" size=\\\"50\\\" type=\\\"file\\\" id=\\\"image$x\\\"><br>\\n\";
} // end for loop to create 4 input fields
echo \"<input type=\\\"submit\\\" name=\\\"submit\\\" value=\\\"Verstuur\\\">\\n\";
echo \"</form>\";
if($_POST[\'submit\']) { // form has been submitted
$num = \'0\';
$sql = \"SELECT * from `test`\";
$sql_result = mysql_query($sql) or die(\"Couldn\'t execute query.\");
while ($row = mysql_fetch_array($sql_result)) {
$id = $row[\"id\"];
if ($id > $num) {
$num == $id;
}
}
$sql = \"INSERT INTO test (id) values (\'$num\');
$result = mysql_query($sql);
for($x=0;$x<$fields;$x++){ // start for loop
$file_name = $_FILES[\'image\'. $x][\'name\'];
$uploads = \'upload\'; // directory to upload to
$copy = copy($_FILES[\'image\'. $x][\'tmp_name\'],$uploads.\'/\'.$file_name);
if($copy) { // check if successfuly copied
$file = \'image$x\';
$sql = \"
UPDATE `test`
SET `$file` = \'$file_name\'
WHERE `id` = \'$num\'
\";
$result = mysql_query($sql); // run SQL query against DB
echo \"$file_name | uploaded successfuly!<br>\\n\";
}else{
echo \"$file_name | could not be uploaded!<br>\\n\";
}
} // end for loop
} // end of submit statement
?>
</body>
</html>
try something like that, i havnt tested it and its just off the top of my head really, but its a basic idea.. or something:\\