Log in

View Full Version : missing something in field add on script here



pkcidstudio
06-09-2006, 08:24 PM
finished, it now allows the user to choose the amnt of fields and allows the user to post them if sql is neede please reply and i can post it.

<?php
require ("functions.php");
session_start();
CheckLogin();

// initialization
$featured_photo_upload_fields = "";
$photo_upload_fields = "";
$counter = 1;

// default number of fields
$featured_number_of_fields = "1";
$number_of_fields = "5";

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

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

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

// this is how you select your amount of photos
if(isset($_POST['add_fields']))
{
$number_of_fields = $_POST['add_fields'];
}

// Category List

$result = mysql_query( "SELECT category_id,category_name FROM gallery_category" );
while( $row = mysql_fetch_array( $result ) )
{
$photo_category_list .=<<<__HTML_END
<option value="$row[0]">$row[1]</option>\n
__HTML_END;
}
mysql_free_result( $result );

// Featured Photo Uploading fields
while( $counter <= $featured_number_of_fields )
{
$featured_photo_upload_fields .=<<<__HTML_END
<tr>
<td>
<p><b>Featured Photo</b> (make sure this is added first)</p>
Photo {$counter}:
<input name=' featured_photo_filename[]' type='file' />
</td>
</tr>
<tr>
<td>
Caption:
<input name='featured_photo_caption[]' type='text' />
</td>
</tr>
__HTML_END;
$counter++;
}

// Photo Uploading fields

while( $counter <= $number_of_fields )
{


$photo_upload_fields .=<<<__HTML_END
<tr>
<td>
<p><b>Photos<b></p>
Photo {$counter}:
<input name=' photo_filename[]' type='file' />
</td>
</tr>
<tr>
<td>
Caption:
<input name='photo_caption[]' type='text' />
</td>
</tr>
__HTML_END;
$counter++;
}

// Final Output
print admin_menu();

echo <<<__HTML_END
<html>
<link rel= "stylesheet" href= "style.css" type= "text/css" />
</head>
<title>upload Photos</title>
</head>
<body>
<table width='400' border='0' align='left' class='blackline'>

<!--begin add fields more images-->
<form action="preupload.php" method="post">

<tr>
<td>
<select name="add_fields" value="add_fields">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="40">40</option>
<option value="80">80</option>
</select>
<input type="submit" name="submit" value="Number of Photos to Upload">
</td>
</tr>
</form>
<!-- stop add fields more images-->

<tr>
<td>
<p>&nbsp;</p>
</td>
</tr>

<!--begin add featured photo -->
<form enctype='multipart/form-data' action='upload.php' method='post' name='upload_form'>

<!--Insert the photo fields here -->
$featured_photo_upload_fields
<!--stop Insert the photo fields here -->

</form>
<!-- stop add featured photo-->

<tr>
<td>
<p>&nbsp;</p>
</td>
</tr>

<!--on release upload images-->
<form enctype='multipart/form-data' action='upload.php' method='post' name='upload_form'>
<tr>
<td>
<input type='submit' name='submit' value='Upload Photos' />
</td>
</tr>
<tr>
<td>
<b>Select Category</b>
<select name='category'>
$photo_category_list
</select>
</td>
</tr>
<!--stop on release upload images-->

<tr>
<td>
<p>&nbsp;</p>
</td>
</tr>

<!--Insert the photo fields here -->
$photo_upload_fields
<!--stop Insert the photo fields here -->


</table>
</form>
</body>
</html>
__HTML_END;


?>