Jump to content

Recommended Posts

I am not the most fluent with PHP but I am with other languages ...

What I am trying to do is one query and list out the info, but for each listing it needs its own query. I may be going about it the wrong way (well obviously since its not working).

[code]function getlist()
{
         global $db;

         $list1 = $db->query_read("
                 SELECT          *
                 FROM            top_list
                 ORDER BY       id
                 ");

          if ($db->num_rows($classlist) == 0)
                  return NULL;

        while($list1row = $db->fetch_array($list1)) {
            
       $list2 = $db->query_read("

                 SELECT          *
                 FROM            top_list_info
                 WHERE listid = $list1row[id]
                 ORDER BY        id
                 ");    

  $retStr .= "

  <tr>
<td class=\"tcat\" colspan=\"6\"><b>$classrow[class_name]</b></td>
</tr>
  <tr>  
  <tr>
<td class=\"alt1\" colspan=\"6\">$classrow[class_desc]</td>
</tr>
     <tr>                              
<td class=\"alt2\" width=\"10%\"><div class=\"smallfont\"><b>Username</b></div></td><td class=\"alt2\"><div class=\"smallfont\"><b>option1</b></div></td><td class=\"alt2\"><div class=\"smallfont\"><b>option2</b></div></td><td class=\"alt2\"><div class=\"smallfont\"><b>option3</b></div></td><td class=\"alt2\" ><div class=\"smallfont\"><b>option4</b></div></td><td class=\"alt2\" width=\"45%\"><div class=\"smallfont\"><b>Notes</b></div></td>
</tr>    


";

    }

         return "$retStr";
    
}

$timelist = getlist();[/code]


This functions fine, but I wanted to add another "while" loop thru the second query but it doesnt like nesting it.

Can anyone get me a step into the right direction?
Link to comment
https://forums.phpfreaks.com/topic/10628-php-nesting/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.