Multiple upload put image names in same database row
<p>hi i have this script that works great but now im trying to get it to add the names of the 3 images to my database in the same database row if you upload 3 images the $extension will show the 3 names of the images but i have no idea how to get the 3 names into the same database row under image1 , images2, images3 anyone have any idea how this can be done? i tried everything i know of with no luck thanks.</p>

<pre><code>`$connection = mysql_connect("localhost", "????", "????");
mysql_select_db("????", $connection);
$uploaddir = "upload/";
$MaxSize = "600000";
$number_of_files = count($_FILES['userfile']);
for($i=0;$i&lt;=$number_of_files;$i++) {
$filename_format = uniqid(Img_);
if (!$_FILES['userfile']['size'][$i] == 0)
{
if ($_FILES['userfile']['size'][$i] &gt; $MaxSize)
{
echo "ERROR: file too big";
exit;}
$tempfile = $_FILES['userfile']['tmp_name'][$i];
$uploadfile = $_FILES['userfile']['name'][$i];
$extension = $_FILES['userfile']['type'][$i];
if (strstr($extension,"jpeg"))
{
$extension=".jpg";
}
elseif (strstr($extension,"gif"))
{
$extension=".gif";
}
elseif (strstr($extension,"png"))
{
$extension=".png";
}
else
{
echo "ERROR: Only gif/jpeg/png allowed.";
exit;
}
if(copy($tempfile, $uploaddir.$uploadfile))
{
echo "Copy Successfull!";
}
else
{
echo "ERROR: something happened trying to copy the temp file to the folder";
}
if(rename($uploaddir.$uploadfile,$uploaddir.$filename_format.$extension))
{
}else{
$query = "INSERT INTO photos (image1, image2, image3) VALUES ('WHAT TO PUT      HERE?','HERE','AND HERE')";  
$result = mysql_query($query);
echo " and renamed to $filename_format$extension";
}
}
else
{
echo "ERROR: Problem renaming the file.. $uploadfile";
}
}`.
</code></pre>
