i have uploaded a group of files and the number of files uploaded is dynamic its value is recieved from form now the name of file type is the number of attachment e.g if 2 files are uploaded then name of 1st file in form will be 1 and name of second file will be 2 so on and so for.i have written the following code


$query="INSERT INTO `complaint` VALUES (NULL , '$name', '$ph_no', '$contact_no', '$type','$date', '$sent_to', '$sent_by')";
mysql_query($query) or die("error in insertion query");
$q="SELECT LAST_INSERT_ID() as last";

$target = "upload/";
$target = $target .date('Y-m-d')."_".$p. "_".$i;
if(move_uploaded_file($_FILES['$p']['tmp_name'], $target)){echo "hello";
$img=date('Y-m-d').time('H:m:s').$p. "_".$i;echo $img;}
$query2="INSERT INTO `history` VALUES ($p, '$img' , '$detail' , '$date', '$sent_to', '$sent_by', '$status')";
mysql_query($query2) or die ("ERRor in insertion query");
echo " your data has been inserted";

hoping for reply soon

What you exactly want?
Does your posted code works? even partially?
And where is html portion?

use [$p] not

or use /upload
and make some folders by month in each year by function mkdir
2.use insert into history inside of if move_uploaded
3.try sql insert into history(field1,field2,fiels3) VALUES('".$val1."','".$val2"' .............
4.test uploaded file by file exists befor creat log in history

make sure file names nothaving "/" or "#" by str_replace