In your snippet you're using two different methods of getting the results from the same dataset, something that is not recommended.
[man]mysql_result()[/man] gets one cell of the dataset at a time and is slow (check the manual page).
[man]mysql_fetch_row()[/man] on the other hand fetchs an entire row of the dataset, quicker.
If you just wanted to fetch the first row of a result set (unlikely) the
$row = mysql_fetch_row($result);
would do it.
The [man]while()[/man] loop loops through the result set until there are no more results, so
while($row = mysql_fetch_row($result)){
$gallery[] =$row;
}
would create an array of the entire result set.
But what think you are trying to achieve would be best done with [man]mysql_fetch_assoc()[/man] so that by doing this
while($row = mysql_fetch_assoc($result)){
$gallery[] =$row;
}
you would get this type of result
Array ( [0] => Array ( [location] => images/01.png
[title] => Title 01
[description] => Description of image 01 )
[1] => Array ( [location] => images/01.png
[title] => Title 01
[description] => Description of image 01 ) )
A tip to better see the structure of your arrays is to enclose them in <pre></pre> tags like this
echo '<pre>';
print_r($gallery);
echo '</pre>';