Page 1 of 1

php photo file array

Posted: Tue Oct 03, 2006 10:55 am
by angel17846
I have a car application where I can upload multiple car images. It works fine when I upload up to 6 pictures, but when I do more, it doesn't recognize but 6 of them. I looked at the size of the array after submission and the number I get is 5...strange. I want to upload 10 photos.

Here is my code now. Please excuse the dust....

Code: Select all

<?php
 require_once('Conn.php'); 

    $images_dir = "../photos";

mysql_select_db($database_Conn, $Conn);
//echo $stock_id;
if($stock_id != "")
{
$numrows = mysql_num_rows(mysql_query("SELECT * FROM specs WHERE stock_id = '$stock_id'", $Conn));

if($numrows > 0)
{
echo "Stock ID is not unique. Please go back and make the Stock ID Unique";
die();
}
}
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "vehicle_form")) {
  $insertSQL = sprintf("INSERT INTO specs (stock_id, `year`, make, model, mileage, price, bodystyle, num_doors, ext_color, int_color, transmission, engine, drivetype, fueltype, cassette, amfm, cdplayer, videosystem, sat_radio, wheels, sunmoon, absbrakes, securitysys, rearwinwipe, remotetrunkrelease, keylessentry, winch, trailerhitch, luggagerack, convertible, tintedwindows, poweroutsidemirrors, towing, powerdoorlocks, childlocks, powerseats, audiosteercontrol, powerwindows, tilt, cruise, powersteering, heatedseats, dualclimate, autoclimate, rearair, navigation, onstar, frontbenchseat, bucket, thirdrow, quad, leather, cloth, memoryseat, dualairbags, driversideairbag, passairbag, sideimpactairbag, comments) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($HTTP_POST_VARS['stock_id'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['year'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['make'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['model'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['mileage'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['price'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['bodystyle'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['num_doors'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['ext_color'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['int_color'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['transmission'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['engine'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['drivetype'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['fueltype'], "text"),
                       GetSQLValueString(isset($HTTP_POST_VARS['cassette']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['amfm']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString($HTTP_POST_VARS['cdplayer'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['videosystem'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['sat_radio'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['wheels'], "text"),
                       GetSQLValueString(isset($HTTP_POST_VARS['sunmoon']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['absbrakes']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['securitysys']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['rearwinwipe']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['remotetrunkrelease']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['keylessentry']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['winch']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['trailerhitch']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['luggagerack']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['convertible']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['tintedwindows']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['poweroutsidemirrors']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['towing']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['powerdoorlocks']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['childlocks']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['powerseats']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['audiosteercontrol']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['powerwindows']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['tilt']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['cruise']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['powersteering']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['heatedseats']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['dualclimate']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['autoclimate']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['rearair']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['navigation']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['onstar']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['frontbenchseat']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['bucket']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['thirdrow']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['quad']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['leather']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['cloth']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['memoryseat']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['dualairbags']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['driversideairbag']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['passairbag']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($HTTP_POST_VARS['sideimpactairbag']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString($HTTP_POST_VARS['comments'], "text"));

  mysql_select_db($database_Conn, $Conn);
  $Result1 = mysql_query($insertSQL, $Conn) or die(mysql_error());


	// initialization
	$result_final = "";
	$counter = 0;

	// List of our known photo types
	$known_photo_types = array( 
						'image/pjpeg' => 'jpg',
						'image/jpeg' => 'jpg',
						'image/gif' => 'gif',
						'image/bmp' => 'bmp',
						'image/x-png' => 'png'
					);
	
	// GD Function List
	$gd_function_suffix = array( 
						'image/pjpeg' => 'JPEG',
						'image/jpeg' => 'JPEG',
						'image/gif' => 'GIF',
						'image/bmp' => 'WBMP',
						'image/x-png' => 'PNG'
					);

	// Fetch the photo array sent by preupload.php
	$photos_uploaded = $_FILES['photo_filename'];

	// Fetch the photo caption array
	$photo_caption = $_POST['photo_caption'];
	
	// Fetch the stock id array
	$stock_id = $_POST['stock_id'];

	while( $counter <= count($photos_uploaded) )
	{
		if($photos_uploaded['size'][$counter] > 0)
		{
			if(!array_key_exists($photos_uploaded['type'][$counter], $known_photo_types))
			{
				$result_final .= "File ".($counter+1)." is not a photo<br />";
			}
			else
			{
				mysql_query( "INSERT INTO gallery_photos(`photo_filename`, `photo_caption`, `stock_id`, `featured`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".($stock_id)."','".addslashes($photo_featured[$counter])."')" );
				$new_id = mysql_insert_id();
				$filetype = $photos_uploaded['type'][$counter];
				$extention = $known_photo_types[$filetype];
				$filename = $new_id.".".$extention;

				mysql_query( "UPDATE gallery_photos SET photo_filename='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" );

				// Store the orignal file
				move_uploaded_file($photos_uploaded['tmp_name'][$counter], 
				 $images_dir . '/' . $filename);


						// Let's get the Thumbnail size
				$size = GetImageSize( $images_dir."/".$filename );
				if($size[0] > $size[1])
				{
					$thumbnail_width = 400;
					$thumbnail_height = (int)(400 * $size[1] / $size[0]);
				}
				else
				{
					$thumbnail_width = (int)(400 * $size[0] / $size[1]);
					$thumbnail_height = 400;
				}
// Build Thumbnail with GD 1.x.x, you can use the other described methods too
				$function_suffix = $gd_function_suffix[$filetype];
				$function_to_read = "ImageCreateFrom".$function_suffix;
				$function_to_write = "Image".$function_suffix;


				// Read the source file
				$source_handle = $function_to_read ( $images_dir."/".$filename ); 
				
				if($source_handle)
				{
					// Let's create an blank image for the thumbnail
				$destination_handle = ImageCreateTrueColor($thumbnail_width, $thumbnail_height); 
				
					// Now we resize it
				ImageCopyResampled($destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1]); 
				}

				// Let's save the thumbnail
				$function_to_write( $destination_handle, $images_dir."/".$filename );
				ImageDestroy($destination_handle );


// third thumbnail size for feature start
						// Let's get the Thumbnail size
				$size = GetImageSize( $images_dir."/".$filename );
				if($size[0] > $size[1])
				{
					$thumbnail_width = 770;
					$thumbnail_height = (int)(770 * $size[1] / $size[0]);
				}
				else
				{
					$thumbnail_width = (int)(770 * $size[0] / $size[1]);
					$thumbnail_height = 770;
				}
// Build Thumbnail with GD 1.x.x, you can use the other described methods too
				$function_suffix = $gd_function_suffix[$filetype];
				$function_to_read = "ImageCreateFrom".$function_suffix;
				$function_to_write = "Image".$function_suffix;

				// Read the source file
				$source_handle = $function_to_read ( $images_dir."/".$filename ); 
				
				if($source_handle)
				{
					// Let's create an blank image for the thumbnail
				$destination_handle = ImageCreateTrueColor($thumbnail_width, $thumbnail_height); 
				
					// Now we resize it
				ImageCopyResampled($destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1]); 
				}

				// Let's save the thumbnail
				$function_to_write( $destination_handle, $images_dir."/f_".$filename );
				ImageDestroy($destination_handle );
				
//end third thumbnail size for feature


				// Let's get the Thumbnail size
				$size = GetImageSize( $images_dir."/".$filename );
				if($size[0] > $size[1])
				{
					$thumbnail_width = 100;
					$thumbnail_height = (int)(100 * $size[1] / $size[0]);
				}
				else
				{
					$thumbnail_width = (int)(100 * $size[0] / $size[1]);
					$thumbnail_height = 100;
				}
			
				// Build Thumbnail with GD 1.x.x, you can use the other described methods too
				$function_suffix = $gd_function_suffix[$filetype];
				$function_to_read = "ImageCreateFrom".$function_suffix;
				$function_to_write = "Image".$function_suffix;

				// Read the source file
				$source_handle = $function_to_read ( $images_dir."/".$filename ); 
				
				if($source_handle)
				{
					// Let's create an blank image for the thumbnail
				$destination_handle = ImageCreateTrueColor($thumbnail_width, $thumbnail_height); 
				
					// Now we resize it
				ImageCopyResampled($destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1]); 
				}

				// Let's save the thumbnail
				$function_to_write( $destination_handle, $images_dir."/tb_".$filename );
				ImageDestroy($destination_handle );
				//
				// new coding


			

				$result_final .= "<img src='".$images_dir. "/tb_".$filename."' /> File ".($counter+1)." Added<br />";
			}
		}
	$counter++;
	}
	$mess = "<p align=\"center\"><font color=blue size=3>Great Job!!<br>A vehicle has been added!<br>Add another below or go back to the <a href=index.php>main page</a></font></p>";
  $insertGoTo = "index.php";
  if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
  }
 // header(sprintf("Location: %s", $updateGoTo));
  
}

$colname_Recordset1 = "1";
if (isset($HTTP_GET_VARS['stock_id'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['stock_id'] : addslashes($HTTP_GET_VARS['stock_id']);
}
mysql_select_db($database_Conn, $Conn);
$query_Recordset1 = sprintf("SELECT * FROM specs WHERE stock_id = %s", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $Conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

?>

<html>
<head>
<title></title>
<link href="../style.css" rel="stylesheet" type="text/css">


<script type="text/javascript">

  function confirm_prompt(text,url) {
    if (confirm(text)) {
      window.location = url;
    }
  }
  </script>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="778" border="0" cellspacing="0" cellpadding="0" background="../images/bg.jpg" align="center">
  <tr> 
    <td><table width="713" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td width="715" colspan="3" align="center" bgcolor="#003466"><img src="../images/fff.jpg" width="653" height="61"></td>
        </tr>
        <tr> 
          <td colspan="3" valign="top"><table width="100%" border="0" cellspacing="4" cellpadding="4" align="center">
              <tr> 
                <td class="admin">
<h2 align="center">Auto Content Manager</h2>
                  <p align="center"><strong>Add A Vehicle</strong></p>
                  <p align="center"><strong><a href="index.php"><< Back 
                    to Auto Manager Home</a><br>
                    </strong></p>
                  <form action="<?php echo $editFormAction; ?>" enctype='multipart/form-data' method="POST" name="vehicle_form">
				 
                    <?=$mess?>
                    <table width="700" border="0" cellspacing="1" cellpadding="0">
                      <tr> 
                        <td width="50" height="21" align="right">&nbsp;</td>
                        <td align="right" class="admin"><p><strong>General:</strong></p></td>
                        <td>&nbsp;</td>
                        <td align="right" class="admin">&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Stock ID: </td>
                        <td>&nbsp; <input name="stock_id" type="text" id="stock_id" size="20"></td>
                        <td align="right" class="admin">Price: </td>
                        <td><input name="price" type="text" id="price" value="" size="20"></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin">&nbsp;</td>
                        <td align="right" class="admin">Year: </td>
                        <td>&nbsp; <input name="year" type="text" id="year" size="20"></td>
                        <td align="right" class="admin">Body Style: </td>
                        <td> <input name="bodystyle" type="text" id="bodystyle" size="20"></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin">&nbsp;</td>
                        <td align="right" class="admin">Make: </td>
                        <td>&nbsp; <input name="make" type="text" id="make" size="20"></td>
                        <td align="right" class="admin" nowrap="nowrap">Number of doors:</td>
                        <td><select name="num_doors" id="num_doors">
                            <option value="" selected>Not Given</option>
                            <option value="2">2</option>
                            <option value="4">4</option>
                            <option value="6">6</option>
                          </select></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin">&nbsp;</td>
                        <td align="right" class="admin">Model: </td>
                        <td>&nbsp; <input name="model" type="text" id="model" size="20"></td>
                        <td align="right" class="admin">Exterior color:</td>
                        <td> <input name="ext_color" type="text" id="ext_color" size="20"></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin">&nbsp;</td>
                        <td align="right" class="admin">Mileage: </td>
                        <td>&nbsp; <input name="mileage" type="text" id="mileage" size="20"></td>
                        <td align="right" class="admin">Interior color: </td>
                        <td> <input name="int_color" type="text" id="int_color" size="20"></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin">&nbsp;</td>
                        <td align="right" class="admin">&nbsp;</td>
                        <td>&nbsp;</td>
                        <td align="right" class="admin">&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin">&nbsp;</td>
                        <td align="right" class="admin"><strong>Motor Specs:</strong></td>
                        <td>&nbsp;</td>
                        <td align="right" class="admin"><strong>Audio/Video:</strong></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin">&nbsp;</td>
                        <td align="right" class="admin">Transmission:&nbsp;</td>
                        <td>&nbsp; <select name="transmission" id="transmission">
                            <option value="automatic">automatic</option>
                            <option value="manual">manual</option>
                            <option value="" selected>Not Given</option>
                          </select></td>
                        <td align="right" class="admin">Cassette: </td>
                        <td><input type="checkbox" name="cassette" id="cassette" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin">&nbsp;</td>
                        <td align="right" class="admin">Engine: </td>
                        <td>&nbsp; <input name="engine" type="text" id="engine" size="20"></td>
                        <td align="right" class="admin">AM/FM Stereo: </td>
                        <td><input type="checkbox" name="amfm" id="amfm" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin">&nbsp;</td>
                        <td align="right" class="admin">Drive Type: </td>
                        <td>&nbsp; <select name="drivetype" id="drivetype">
                            <option value="" selected>Not Given</option>
                            <option value="4 Wheel Drive">4 Wheel Drive</option>
                            <option value="Rear Wheel Drive">Rear Wheel Drive</option>
                            <option value="Front Wheel Drive">Front Wheel Drive</option>
                          </select></td>
                        <td align="right" class="admin">CD Player:</td>
                        <td><select name="cdplayer" id="cdplayer" width="15">
                            <option value="" selected>None</option>
                            <option value="Single CD">Single CD</option>
                            <option value="CD Changer">CD Changer</option>
                          </select></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin">&nbsp;</td>
                        <td align="right" class="admin">Fuel Type: </td>
                        <td>&nbsp; <select name="fueltype" id="fueltype">
                            <option value="" selected>Not Given</option>
                            <option value="Gas">Gas</option>
                            <option value="Diesel">Diesel</option>
                          </select></td>
                        <td align="right" class="admin">Video System: </td>
                        <td><select name="videosystem" title="videosystem">
                            <option value="" selected>Not Given</option>
                            <option value="VHS">VHS</option>
                            <option value="DVD">DVD</option>
                            <option value="DVD and VHS">DVD and VHS</option>
                          </select></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td>&nbsp;</td>
                        <td align="right" class="admin">Satellite Radio: </td>
                        <td><select name="sat_radio" id="sat_radio" width="15">
                            <option value="" selected>None</option>
                            <option value="XM">XM</option>
                            <option value="Sirius">Sirius</option>
                          </select></td>
                      </tr>
                    </table>
                    <br>
                    <table width="700" border="0" cellspacing="1" cellpadding="0">
                      <tr> 
                        <td align="right" class="admin" width="50">&nbsp;</td>
                        <td align="right" class="admin"><strong>Exterior Features: </strong></td>
                        <td>&nbsp;</td>
                        <td align="right" class="admin"><strong>Interior Features: </strong></td>
                        <td>&nbsp;</td>
                        <td align="right" class="admin"><strong>Seating:</strong></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Wheels: </td>
                        <td><select name="wheels">
                            <option value="Alloy">Alloy</option>
                            <option value="Aluminum">Aluminum</option>
                            <option value="Chrome">Chrome</option>
                            <option selected value="">Not Given</option>
                          </select></td>
                        <td align="right" class="admin">Power Door Locks: </td>
                        <td><input type="checkbox" name="powerdoorlocks" id="powerdoorlocks" value=""></td>
                        <td align="right" class="admin">Front Bench Seats: </td>
                        <td><input type="checkbox" name="frontbenchseat" id="frontbenchseat" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Towing Package</td>
                        <td><input type="checkbox" name="towing" id="towing" value=""></td>
                        <td align="right" class="admin">Child Safety Locks: </td>
                        <td><input type="checkbox" name="childlocks" id="childlocks" value=""></td>
                        <td align="right" class="admin">Bucket Seats: </td>
                        <td><input type="checkbox" name="bucket" id="bucket" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Power Outside Mirrors:</td>
                        <td><input type="checkbox" name="poweroutsidemirrors" id="poweroutsidemirrors" value=""></td>
                        <td align="right" class="admin">Power Seats: </td>
                        <td><input type="checkbox" name="powerseats" id="powerseats" value=""></td>
                        <td align="right" class="admin">3rd Row Seating: </td>
                        <td><input type="checkbox" name="thirdrow" id="thirdrow" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Sunroof/Moonroof: </td>
                        <td><input type="checkbox" name="sunmoon" id="sunmoon" value=""></td>
                        <td align="right" class="admin">Audio Steering Wheel Controls: </td>
                        <td><input type="checkbox" name="audiosteercontrol" value=""></td>
                        <td align="right" class="admin">Quad Seating</td>
                        <td><input type="checkbox" name="quad" id"quad" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">ABS Braking System:</td>
                        <td><input type="checkbox" name="absbrakes" id="absbrakes" value=""></td>
                        <td align="right" class="admin">Power Windows: </td>
                        <td><input type="checkbox" name="powerwindows" id="powerwindows" value=""></td>
                        <td align="right" class="admin">Leather Seats: </td>
                        <td><input type="checkbox" name="leather" id="leather" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Security System</td>
                        <td><input type="checkbox" name="securitysys" id="securitysys" value=""></td>
                        <td align="right" class="admin">Tilt Steering: </td>
                        <td><input type="checkbox" name="tilt" id="tilt" value=""></td>
                        <td align="right" class="admin">Cloth Seats: </td>
                        <td><input type="checkbox" name="cloth" id="cloth" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Rear Window Wiper: </td>
                        <td><input type="checkbox" name="rearwinwipe" id="rearwinwipe" value=""></td>
                        <td align="right" class="admin">Cruise Control:</td>
                        <td><input type="checkbox" name="cruise" id="cruise" value=""></td>
                        <td align="right" class="admin">Memory Driver&#8217;s Seat: </td>
                        <td><input type="checkbox" name="memoryseat" id="memoryseat" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Remote Trunk Release:: 
                        </td>
                        <td><input type="checkbox" name="remotetrunkrelease" id="remotetrunkrelease" value=""></td>
                        <td align="right" class="admin">Power Steering:</td>
                        <td><input type="checkbox" name="powersteering" id="powersteering" value=""></td>
                        <td align="right" class="admin">Heated Front Seats: </td>
                        <td><input type="checkbox" name="heatedseats" id="heatedseats" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Remote Keyless Entry: 
                        </td>
                        <td><input type="checkbox" name="keylessentry" id="keylessentry" value=""></td>
                        <td align="right" class="admin">Dual Climate Control:</td>
                        <td><input type="checkbox" name="dualclimate" id="dualclimate" value=""></td>
                        <td align="right" class="admin">&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Winch:</td>
                        <td><input type="checkbox" name="winch" id="winch" value=""> 
                        </td>
                        <td align="right" class="admin">Auto-Climate:</td>
                        <td><input type="checkbox" name="autoclimate" id="autoclimate" value=""></td>
                        <td align="right" class="admin"><strong>Airbags: </strong><br></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Trailer Hitch:</td>
                        <td><input type="checkbox" name="trailerhitch" id="trailerhitch" value=""></td>
                        <td align="right" class="admin">Rear Air Control</td>
                        <td><input type="checkbox" name="rearair" id="rearair" value=""> 
                        </td>
                        <td align="right" class="admin">Dual: </td>
                        <td><input type="checkbox" name="dualairbags" id="dualairbags" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Luggage Rack: </td>
                        <td><input type="checkbox" name="luggagerack" id="luggagerack" value=""></td>
                        <td align="right" class="admin">Navigation System: </td>
                        <td><input type="checkbox" name="navigation" id="navigation" value=""></td>
                        <td align="right" class="admin">Driver side:</td>
                        <td><input type="checkbox" name="driversideairbag" id="driversideairbag" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Convertible Top: </td>
                        <td><input type="checkbox" name="convertible" id="convertible" value=""></td>
                        <td align="right" class="admin">On Star: </td>
                        <td><input type="checkbox" name="onstar" id="onstar" value=""></td>
                        <td align="right" class="admin">Passenger side: </td>
                        <td><input type="checkbox" name="passairbag" id="passairbag" value=""></td>
                      </tr>
                      <tr> 
                        <td align="right" class="admin" nowrap="nowrap">&nbsp;</td>
                        <td align="right" class="admin" nowrap="nowrap">Tinted Windows:</td>
                        <td><input type="checkbox" name="tintedwindows" id="tintedwindows" value=""></td>
                        <td align="right" class="admin">&nbsp;</td>
                        <td>&nbsp;</td>
                        <td align="right" class="admin">Side Impact: </td>
                        <td> <input type="checkbox" name="sideimpactairbag" id="sideimpactairbag" value=""></td>
                      </tr>
                    </table>
                    <br>
                    <table width="700" border="0" cellspacing="2" cellpadding="2">
                      <tr> 
                        <td width="50">&nbsp;</td>
                        <td align="right" class="admin" width="160" valign="top" nowrap="nowrap">Additional&nbsp;<br>
                          Comments:</td>
                        <td align="left"><textarea name="comments" cols="50" rows="6" id="comments" value=""></textarea></td>
                      </tr>
                      <tr> 
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr> 
                        <td>&nbsp;</td>
                        <td colspan="2" align="center">&nbsp; </td>
                      </tr>
                    </table>
                    <?php

	include("config.inc.php");
	
	// initialization
	$photo_upload_fields = "";
	$counter = 1;

	// default number of fields
	$number_of_fields = 6; 

// If you want more fields, then the call to this page should be like, 
// preupload.php?number_of_fields=20

	if( $_GET['number_of_fields'] )
	$number_of_fields = (int)($_GET['number_of_fields']);

// Lets build the Photo Uploading fields
	while( $counter <= $number_of_fields )
	{
$photo_upload_fields .=<<<__HTML_END
<tr>
	<td class="admin">
	     Photo {$counter}:
		  <input type='hidden' name='MAX_FILE_SIZE' value='100000000' />
	    <input name='photo_filename[]' type='file' />
	</td>
</tr>
<tr>
	<td class="admin">
	     Set Featured:
	   <input type=checkbox name = 'photo_featured[]' value= '1'>
	</td>
</tr>
__HTML_END;
	$counter++;
	}

// Final Output
echo <<<__HTML_END

<table align=center>
<!-Insert the photo fields here -->
$photo_upload_fields

<tr>
	<td>
	        <input type='submit' name='submit' value='Submit' />
	</td>
</tr>
</table>
__HTML_END;
?>
                    <p>
                      <input type="hidden" name="MM_insert" value="vehicle_form">
                    </p>
                    </form>
                  
                </td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table>
	  </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
I tried changing the default size on line 640 and changing the number using a URL variable, but neither works. Any help would be appreciated. I think I just need an extra set of eyes on this one as I'm sure I'm missing something simple.

Angel

echo variable

Posted: Wed Oct 04, 2006 1:19 pm
by churt
You may have done this already but did you try to echo the $photos_uploaded variable just before the start of the while loop? Just to make sure the number getting to the loop is correct.