Hey everyone,
I'm very much a newbie, so if you can and do kindly respond, keep in mind that my knowledge is limited.
I'm working on a page for school, and I'm having some difficulty with the last part of the project.
What I have is basically a MySQL db that I'm trying to first take info from and then, using checkboxes, allow the users to select displayed photographs to add to an album. However, I keep running into snags. It has to run so that however many pictures the user formerly uploaded, there are checkboxes and options to add to the overall album. This requires multiple loop structures and gets really confusing for me and I just can't get it to work right.
Anyways, enough of my ranting, here's the hard code which doesn't completely work:
PHP:--------------------------------------------------------------------------------
//album.php page
$chk_cnt = 0;
while($row = mysql_fetch_array($result))
{
$image_id = $row['image_id'];
$name = $row['name'];
$type = $row['type'];
$date_taken = $row['date_taken'];
$size_file = $row['size_file'];
$original_name = $row['original_name'];
$place = $row['place'];
$location_of_imagefile = $row['location_of_imagefile'];
$description = $row['description'];
$category = $row['category'];
$photo_display = $name;
$row++;
$size_file = ($size_file/1048576);
//URL to see the picture and the accompanying info
echo "<img src=\"/nat_geo/images/$original_name\">
<BR><strong>Name: </strong>$name
<BR><strong>Date taken: </strong>$date_taken
<BR><STRONG>Size: </strong>$size_file MB
<BR><STRONG>Location: </STRONG>$place
<BR><STRONG>Category: </STRONG>$category
<BR><STRONG>Description: </STRONG>$description
<BR>";
$image_array[$chk_cnt]=$image_id;
$name_array[$chk_cnt]=$name;
$chk_cnt++;
}
if ($chk_cnt < 3)
{
echo "<h1>You do not have enough pictures for an album</h1>";
} else
{
?>
<FORM METHOD="POST" ACTION="do_album_create.php">
<!--Let the user create an album name-->
<P align="center"><STRONG>Album Name:</STRONG><BR>
<INPUT TYPE="text" NAME="name_album" SIZE=25 MAXLENGTH=20>
</P>
<!--Let the user give a description of the album-->
<CENTER>
<p><strong>Give a brief description of your album:</strong></p>
<P><TEXTAREA NAME="description" COLS=50 ROWS=10 WRAP=virutal>
</TEXTAREA></P>
<!--Check boxes to add picutres-->
<p><strong>Choose pictures to add:</strong></P>
<?
for ($i=0; $i < $chk_cnt; $i++)
{
<INPUT TYPE="checkbox" NAME="$image_array[$i]\" VALUE=\"1\" checked>$name_array[$i]<BR>";
}
?>
<INPUT TYPE="hidden" VALUE="full_name" NAME="$full_name">
<INPUT TYPE="hidden" VALUE="$chk_cnt" NAME="chk_cnt">
<INPUT TYPE="hidden" VALUE="$image_array[]" NAME="image_array">
<INPUT TYPE="hidden" VALUE="$name_array[]" NAME="name_array">
<INPUT TYPE="submit" NAME="submit" VALUE="Create Album"></P></form></CENTER>
<?
}
?>
What am I doing wrong on this page? Should I use a different type of counter? I basically just want to pass the image_ids from this page to the next based on the checkboxes. Would JS be the way to go? I'm driving myself nuts, so any help is greatly, greatly appreciated on both the front and back of this script.