califdon wrote:Seems to me like you don't need 2 lookups here. You seem to be assuming that there can only be one row in photo_album with any given title, anyway, why not just return the gid value in the first query? In a real database, that is probably an unwise assumption unless you have declared the title to be the primary key, which it doesn't appear that you have. What happens if there are more than one row with a given title? I don't think your first query handles that.
Ah, you're right. I can just get the aid from the first page. Unfortunately, I'm still having the issue of getting aid in a usable form to create directories with.
Can you guys help me get aid as an integer? I'm going crazy trying to get this thing out of the array into an integer form.
So I've got two pages: upload_pic.php and describe_pic.php.
Here's some relevant code from upload_pic.php.
Code: Select all
<form enctype="multipart/form-data" action="describe_pic.php" method="POST">
<h1>Upload Pictures to Album</h1>
<br />
Select Album:
<select name="aid">
<?php
$result_album = mysql_query('SELECT * FROM photo_album') or die(mysql_error());
while($row_album = mysql_fetch_array($result_album))
{
echo "<option value=".$row_album['aid'].">".$row_album['title']."</option>";
}
?>
</select>
...
<input type="submit" value="Submit" name="submit"/>
</form>
Here's the fixed describe_pic.php:
Code: Select all
// get aid
$aid = $_POST['aid'];
//$sql_aid = "SELECT * FROM photo_album WHERE title='$album'";
//$result_aid = mysql_query($sql_aid) or die(mysql_error());
//$array_aid = mysql_fetch_array($result_aid);
//$aid = $array_aid['aid']; // format
// get gid associated w/ aid
$sql_gid = "SELECT gid FROM photo_album WHERE aid='$aid'";
$result_gid = mysql_query($sql_gid) or die(mysql_error());
$array_gid = mysql_fetch_array($result_gid);
$gid = $array_gid['gid'];
// DEBUG
echo "aid: $aid";
echo "<br />";
echo "aid array: ".print_r($array_aid);
echo "<br />";
echo "gid: $gid";
echo "<br />";
echo "gid array: ".print_r($array_gid);
echo "<br />";
$aid_set = var_dump(isset($aid));
echo "is aid set? $aid_set";
Unfortunately, my output on describe_pic.php is still the same:
Code: Select all
aid:
aid array: 1
gid:
gid array: 1
bool(false) is aid set?