Results 1 to 4 of 4

Thread: [RESOLVED] dataset within dataset/list within a list

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    London
    Posts
    107

    Resolved [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).

  2. #2
    Frenzied Member
    Join Date
    Feb 2008
    Location
    Texas
    Posts
    1,288

    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
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    London
    Posts
    107

    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...

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    London
    Posts
    107

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width