Hi,
I'm trying to make two stored proc calls with mysqli_multi_query to bind a grid and a dropdown.
I have followed the code example from the PHP manual, got the grid/table to bind, but I can't fetch the second result set for the dropdown.
Here is my code:
<?
$query = "CALL ListAllItemOnRecord;";
$query .= "CALL GetListData('varietal');";
if ($db->multi_query($query)) {
if ($result = mysqli_store_result($db)) {
if (mysqli_num_rows($result) > 0) {
?>
<table>
<thead>
<tr>
<th align="center">Col1</th>
<th align="center">Col2</th>
<th align="center">Col3</th>
</tr>
</thead>
<tbody>
<?
while($row = mysqli_fetch_assoc($result)) {
print "<tr><td></td>";
print "<td class=\"bodybox\">".$row['field1']."</td>";
print "<td class=\"bodybox\">".$row['field2']."</td>";
print "<td class=\"bodybox\">".$row['field3']."</td></tr>";
}
}
$result->free();
}
?>
</tbody>
</table>
<?
//<select name="varietal">
if (mysqli_more_results($db) && mysqli_next_result($db)) {
echo("test1");
if ($result = mysqli_store_result($db)) {
while($row = mysqli_fetch_assoc($result)) {
echo("test2");
//echo "<option value=\"$row[1]\" $selected>$row[1]</option>";
}
$result->free();
}
}
}
//</select>
?>
Notice how I commented out the HTML for the dropdown. By running the code I see the grid, and then "test1" but no "test2", which leads me to think the code detected a second result set but couldn't store it.
I've confirmed both stored proc calls return a result set.
Am I doing something wrong in the code? Can someone please shed some light? Thanks!