tags:

views:

44

answers:

2

This is the function that im calling.

function GetSubmissions($coach){
    $result = mysql_query("SELECT * FROM `ptable` WHERE coach = '$_SESSION[username]'") or trigger_error(mysql_error()); 
    while($row = mysql_fetch_array($result)){ 
    foreach($row AS $key => $value) { $row[$key] = stripslashes($value); } 
     $id = $row['id'];
     $teampre = $row['team'];
     $eventpre = $row['event'];
     $statuspre = $row['status'];
     $eventarray = DecodeEvent($eventpre);
      $event = $eventarray[0];
      $cat = $eventarray[1];
      $subcat = $eventarray[2];
      $division = $eventarray[3];
      $type = $eventarray[4];
     $teamarray = explode(",", $teampre);
      foreach ($teamarray AS $tkey => $tvalue){
       $result = mysql_query("SELECT * FROM `students` WHERE id = '$tvalue'") or trigger_error(mysql_error()); 
       while($row = mysql_fetch_array($result)){ 
       foreach($row AS $skey => $svalue) { $row[$skey] = stripslashes($svalue); } 
       $firstname = $row['firstname'];
       $lastname = $row['lastname'];
       $teamgo .= "$firstname $lastname<br/>";
       }

    }  
     $push .= "<div id=submission><div id=event>$event</div><div id=status>$statuspre</div><div id=subinfo>$cat $subcat $division $type</div><div id=team>$teamgo</div></div>";
    }   

 return $push;
}

It works, except its only returning a single result. Ive made little tweaks here and there, but im not seeing any positive changes in the output. Any ideas where im going wrong?

+2  A: 

You have nested $result variables. You should try to avoid using the same variable name twice. Renaming the second one inside your second foreach loop would probably do the trick.

cballou
this worked, but im getting repeating results on the second loop
Patrick
+1  A: 

You use the same $result for inner loop.

Michael Krelin - hacker