Hi. Any help would be great! Thanks in advance.

I have a prepared statement to fetch several rows of data from mysql. For each row fetched I'd like to run another prepared statement to fetch more data, based on the rows returned in the first prepared statement. I'm sure there is a better way of doing this.

I get the error: Warning: mysqli::prepare() [function.mysqli-prepare]: All data must be fetched before a new statement prepare takes place in...

Here is my code:
Code:
$puid = $_GET['puid'];
require('connection.inc.php');
$conn = dbConnect(); //connection to db funtion in connection.inc.php
$sql = "SELECT pictureid, comment FROM pictures WHERE userid = ?";
$result = $conn->prepare($sql);
$result->bind_param("i", $puid);
$result->execute();
$result->bind_result($pictureid, $comment);
while($result->fetch()) {
	$sql = "SELECT (SELECT count(*) FROM choices WHERE chosen = ?) AS chosenCount, (SELECT count(*) FROM choices WHERE chosen = ? OR notchosen = ?) AS chosenTotal";
	$result2 = $conn->prepare($sql);
	$result2->bind_param("iii", $pictureid, $pictureid, $pictureid);
	$result2->execute;
}