SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    output display repeatedly

    Hi, I need some help please,why is it that my $rmx is displaying repeatedly.even it is not matched to the $s_id ?



    PHP Code:
        $command=$db->prepare('SELECT * from employee where id = ?');
        
    $command->execute(array($empid));


     while(
    $record=  $command->fetch(PDO::FETCH_ASSOC)){
                
    $s_id $record['s_id'];
                       
                      
    $cmmmand2 $db->prepare("SELECT * from office where off_id = ?");
                   
    $command2->execute(array($s_id));
                 
                  while(
    $record2 $command2->fetch(PDO::FETCH_ASSOC)){
                        
    $rmx.=$record2['off_server'].'<br/>';
                  
                  }        
                    
                
    $data.= '<div class="myoffice"><p>'.$record['office_name'].'<br/>'.$rmx.'</div>';
                
                 
            } 
    The output is like this.it continues to display in my A02rm

    Code:
    A01rm
    server1
    server2
    
    
    A02rm
    server1
    server2
    server3
    server4
    I want that the output should like this.

    Code:
    A01rm
    server1
    server2
    
    
    A02rm
    server3
    server4

    Please help me on this.

    Thank you in advance.
    Last edited by jemz; Oct 4, 2013 at 13:54. Reason: I got it now

  2. #2
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Sorry for my post...I think i solved it now...

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2005
    Location
    Michigan, USA
    Posts
    434
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No need to apologize for posting but you should post the solution for everyone else to learn from. I see the required solution as being that $rmx needs to be initialized in the outer loop.
    - Robert


Bookmarks

Posting Permissions

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