0

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 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

this worked, but im getting repeating results on the second loop
1

You use the same $result for inner loop.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.