I don't understand what your trying to do with this line:
if($other_row['album_id'] == $row['album_id'])
Where is $row defined?
If you want only certain rows, then use the "WHERE" clause just like in your original post. Maybe I misunderstood what you want.
If you want to retrieve just the four rows, then do:
// I don't know where $row is set!
$other_sql = "SELECT id FROM `tbl_images` WHERE `album_id` = '".$row['album_id']."'";
$other_query = mysql_query($other_sql) or die(mysql_error());
while($other_row = mysql_fetch_array($other_query))
{
$next_row[] = $other_row['id'];
}
If you want to retrieve all row ID's, then do:
$other_sql = "SELECT * FROM `tbl_images`"
$other_query = mysql_query($other_sql) or die(mysql_error());
while($other_row = mysql_fetch_array($other_query))
{
$next_row[] = $other_row['id'];
}