Alright, well I followed one of sitepoints articals on how to build a php photo gallery with categories and sub categories (http://articles.sitepoint.com/article/php-gallery-system-minutes) and am having some issues…
After closely following the tutorial and writing up the code, it seems that I can’t get the photo_category_list to work in any of the pages. Because of this, I am unable to post an uploaded photo onto the viewgallery.php page… Also something else to note is that the photo category’s aren’t even showing up in the select box on the preupload.php page when I go to upload a photo.
Here is the code I am using for my preupload.php page:
<?php
include("config.inc.php");
// initialization
$photo_upload_fields = "";
$counter = 1;
// default number of fields
$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['number_of_fields'] )
$number_of_fields = (int)($_GET['number_of_fields']);
// Firstly Lets build the 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>\
__HTML_END;
}
mysql_free_result( $result );
// Lets build the Photo Uploading fields
while( $counter <= $number_of_fields )
{
$photo_upload_fields .=<<<__HTML_END
<tr>
<td>
Photo {$counter}:
<input name=' photo_filename[]' type='file' />
</td>
</tr>
<tr>
<td>
Caption:
<textarea name='photo_caption[]' cols='30' rows='1'></textarea>
</td>
</tr>
__HTML_END;
$counter++;
}
// Final Output
echo <<<__HTML_END
<html>
<head>
<title>Lets upload Photos</title>
</head>
<body>
<form enctype='multipart/form-data' action='upload.php' method='post' name='upload_form'>
<table width='90%' border='0' align='center' style='width: 90%;'>
<tr>
<td>
Select Category
<select name='category'>
$photo_category_list
</select>
</td>
</tr>
<tr>
<td>
<p> </p>
</td>
</tr>
<!-Insert the photo fields here -->
$photo_upload_fields
<tr>
<td>
<input type='submit' name='submit' value='Add Photos' />
</td>
</tr>
</table>
</form>
</body>
</html>
__HTML_END;
?>
What am I doing wrong? Why aren’t the photo categories appearing on the preupload.php page? Thanks for any and all help on this.