Forum Moderators: coopster
<input name=\"_Pic1\" type=\"file\" value='$image1' /><img src=\"../images/carpictures/$image1\">
function image_list($script,$prod_id) {
$images_table= IMAGES_TABLE; // database table for images, set from constant
$output= NULL; // Avoiding concatenation errors
$imgs_url= IMAGES_RELATIVE_DIR; // For URL's, /uploads, note not the same as full path
$imgs_path= USED_IMGS_DIR; // full path, /var/www/example.com/uploads
$ul_field= 'my-upload'; // Name of file object
$new_seq= 'img_seqence'; // See notes below
//
if ($prod_id > 0) {
// This puts all the ones with assigned numbers ABOVE unset values, which are 0 (zero)
$query = "select id,seq,file,original_fname from $images_table" .
" where prod_id=$prod_id order by sequence>0 desc, sequence";
$result=mysql_query("$select");
if (!$result) { error("Cannot get images for product $prod_id: " . mysql_error()); }
while ($row=mysql_fetch_array($result)) {
//
$file = $row['file'];
$orig = $row['original_fname'];
$delname = 'del_img_' . $row['id']; // Name of our delete checkbox
$seqname = 'img_seq_' . $row['id']; // name of the sequence dropdown
$seqvalue = $row['sequence']; // To populate selected
// This is a function you will need to write, pretty simple. Generates select list
$seq_list = sequence_list($seqname,$images_table,$seqvalue);
// Use GD, if you must. :-) Note this is NOT the URL, full server path
$image = new Imagick("$imgs_path/$file");
$w = $image->getImageWidth();
$h = $image->getImageHeight();
$image->destroy();
//
// Note the use of $img_url below, and the newWin function,
// you'll have to write Javascript for it.
// My "newWin" accepts url, title, width, height,
// and returns false.
$output .= "
<tr>
<td><input type=\"checkbox\" name=\"$delname\" id=\"$delname\"></td>
<td colspan=\"2\">
<a href=\"$imgs_url/$file\"
onclick=\"return newWin('','$imgs_url/$file','$orig',$w,$h);\">$orig</a></td>
<td class=\"$center_style\">$seq_list</td>
<td> </td>
</tr>
";
} // End if $prod_id
mysql_free_result($result);
} // End while
//
if ($output) {
$output = "
<tr><td colspan=\"3\"> </td></tr>
<tr>
<td class=\"$reverse_style\">DELETE</td>
<td colspan=\"2\">PREVIEW</td>
<td>SEQUENCE</td>
</tr>
$output
";
}
//
// Re-get the sequence list for the NEW upload
$sequence_list = sequence_list($new_seq,$images_table,null);
//
$output .= "
<tr><td colspan=\"3\"> </td></tr>
<tr>
<td nowrap><label for=\"$ul_field\">Add Image:</label></td>
<td colspan=\"2\" nowrap>
<input type=\"file\" name=\"$ul_field\" id=\"$ul_field\">
<label for=\"$new_seq\">#</label> $sequence_list
</td>
</tr>
";
return $output;
}