Forum Moderators: coopster
My client is a photographer and wants to upload multiple photos at a time.
what i normally do is, make input files name them and pass variables to another page, then move the files into the server and insert the route into the database.
problems is, if this guy wants to upload 50 at a time ive gotta build a page with 50 file inputs and then do the inserts etc.
what im trying to do is :
Ive made a page where theres a text box for you to type in the number of photos you want to upload.
the hidden $amount variable then gets sent to _SELF and when the page reloads there is a while loop that draws a table with the number of input files you want, kind of like this...
<form id="form1" name="form1" method="post" action="">
<div align="center">
<select name="clientid" class="boxes" id="clientid">
<option>Choose a client</option>
<?
$i = 0;
while($i<$num){
$clientid = mysql_result($rs,$i,"clientid");
?>
<option value="<?php echo "$clientid"?>"><?php echo "$clientid"?></option>
<?
++$i;
}
?>
</select>
<input name="amount" type="text" class="boxes" id="amount" value="Enter amount" onfocus="this.value=''" />
<input type="submit" name="Submit" value="Load Results" />
</div>
</form>
<p>
<?php
if ($clientid!= ""){
?>
</p>
<table width="700" border="1" align="center" cellpadding="4" cellspacing="4" class="minipicborder">
<tr>
<td width="123"><div align="center">image Title </div></td>
<td width="130"><div align="center">Image Thumb </div></td>
<td width="136"><div align="center">Image Big</div></td>
<td width="135"><div align="center">Image Super </div></td>
<td width="47"><div align="center">Gallery</div></td>
<td width="39"><div align="center">Active</div></td>
</tr>
</table>
<form id="form2" name="form2" method="post" action="admin_add_pics_do.php">
<?
$x = 0;
while($x<$num2){
?>
<table width="700" border="1" align="center" cellpadding="4" cellspacing="4" class="minipicborder">
<tr>
<td width="121"><input name="image_title" type="text" id="image_title_<? echo "$x"?>" size="16" /></td>
<td width="128"><input name="image_small" type="file" class="greybg" id="image_small_<? echo "$x"?>" size="4" /></td>
<td width="136"><input name="image_big" type="file" class="greybg" id="image_big_<? echo "$x"?>" size="4" /></td>
<td width="134"><input name="image_super" type="file" class="greybg" id="image_super_<? echo "$x"?>" size="4" /></td>
<td width="51"><div align="center">
<input name="gal" type="checkbox" id="gal_<? echo "$x"?>" value="1" />
</div></td>
<td width="40"><div align="center">
<input name="active" type="checkbox" id="active<? echo "$x"?>" value="1" />
</div></td>
</tr>
</table>
<br />
<?
++$x;
}
?>
<br />
<table width="700" border="0" align="center" cellpadding="4" cellspacing="4">
<tr>
<td><div align="center">
<input type="submit" name="Submit2" value="Upload Photos" />
<input name="amount" type="hidden" id="amount" value="<?php echo "$amount"?>" />
<input name="clientid" type="hidden" id="clientid" value="<?php echo "$clientid"?>" />
</div></td>
</tr>
</table>
</form>
<p>
<?
}
?>
</p>
So what i did was, do the forms above with the while loops, i had to put the counter into the name of the variables for the next part of my idea.
Once ive made this form, which works by the way :)
I want to send the variables through to another page and gather them for an insert on a while loop.
This is where im stuck,
im trying to get variables from the previous page, but the variables are dependent on the $AMOUNT variable chosen previously,
so ive kinda got this which i know is wrong but need help on how to request the posted variabes and insert them into a DB
can i use a while loop on the second page to gather the variables from the previous?
then do another while loop for the move files and insert script?
help...
the second bit look like this so far,
$clientid = $_POST["clientid"];
$amount = $_POST["amount"];
$x = 0;
while ($x<$amount){
$image_title = $_POST["image_title_$x"];
$gallery = $_POST["gallery_$x"];
$active = $_POST["active_$x"];
++$x;
}
many regards,
I know this is a bit meaty but had to write this much to try and explain the situation,
thanx in advance
Diegomh7