[RESOLVED] dataset within dataset/list within a list
I'm trying to display a list of data within a larger list, as a rough example:
First List Row 1 --->Second List A
--->Second List B
--->Second List C
First List Row 2 --->Second List A
First List Row 3 --->Second List B
--->Second List C
...and so on...
I've tried to simplify my code, so it only includes two fields, but the result is the same, it only shows 1 result:
(i.e. First List Row 1 --->Second List A
--->Second List B
--->Second List C)
Here is the code:
<html>
<head>
<title>View Issues</title>
</head>
<body marginheight="0" topmargin="0" marginwidth="0"
leftmargin="0" style="margin:0;padding:0" bgcolor="#B0E0E6">
<form action="add_issue3.php" method="post">
<?php
include_once('functions.php');
$db = new mysqli('HOSTNAME', 'USER', 'PASSWORD', 'DATABASE');
$query = "call sp_filter_issues_description(1,'BACR%')";
$result = $db->query($query);
$num_results = $result->num_rows;
while($row = $result->fetch_assoc())
{
?>
<table border="1" style="border:solid black" cellpadding="0"
cellspacing="0" width="100%">
<tr>
<td>
<?php echo $row['currency_ticker'];?>
</td>
<td>
<table width='100%'>
<?php
$db1 = new mysqli('HOSTNAME', 'USER', 'PASSWORD', 'DATABASE');
$query1 = "call sp_bookrunner(100)";
$result = $db1->query($query1);
$num_results = $result->num_rows;
while($row = $result->fetch_assoc())
{
echo "<tr><td>".$row['bond_ticker']."</td></tr>";
}
$db1->close;
?>
</table>
</td>
</tr>
</table>
<?php }
$db->close();
?>
</form>
</body>
</html>
(Just while testing, I hardcoded the row id, so the 100 you see going into the stored procedure would be a variable in reality, I just wanted to check the code worked first, before assigning a variable).
Re: dataset within dataset/list within a list
You're updating your $result variable in the nested while. So by the time your inner while completes, when it goes back up to the outer, there are no more fetches left to do. Use $iresult or $tickers for the results of your inner query.
Justin
Re: dataset within dataset/list within a list
Yep, I changed my approach, (for each....irow++ if that makes sense), rather than using while($row = $result), however now I've come across a new problem. That approach works fine whilst I am simply trying to display data to view.
Still seems to be a problem, as some results are unexpected, but I suspect the problem is with my SQL...will report back...
Re: dataset within dataset/list within a list
Yep, this works, I have a releated problem around list boxes, but I'll mark this as resolved (now that I've learnt how to do that) and start a new thread.