While inside another while loop with MySQL

could someone give me a hint here, because I am trying to resolve the problem I have for some time, and I am getting nowhere for now.

I have one while loop which is listing all players from one team, and need to list their statistics. I tried with nested while loop, but I am not getting any results printed.

<?php 
while($player=mysql_fetch_array($var2)) {
    echo $player[1] ." ". $player[2] ." ". $player[3] ." ". $player[4] ." "; 
    $goal=mysql_query("SELECT A.Minute+A.Minuteadditional from Appearance A 
    where A.Type=1 and A.Appearance_ID in (Select M.ID_Matches from Matches M 
    where M.Player_ID=$player[0] and M.Match_ID=$match)",$connection);

    while($g=mysql_fetch_array($goal)) {
        echo $g[0] .", ";
    }
    echo "<br>"; 
}
?>

Here I tried to get all minutes when specific player scored (printed on right from his name). Query has results in phpMyadmin, but code returns no results here.

$player[0] is a player ID, and rest of fields are shirt number, last name, surname etc... I know that having query inside a loop is not recommended, but I am still beginner with php and this way looks to me the most logical and easier to understand.

Answers


if you using

$player[1] ." ". $player[2] ." ". $player[3] ." ". $player[4]

then i guess you should use mysql_fetch_row instead.

then your code will be

 while($player=mysql_fetch_row($var2)) {

Try this

<?php 
 $player=mysql_fetch_row($var2);

 $goal=mysql_query("SELECT A.Minute+A.Minuteadditional from Appearance A 
 where A.Type=1 and A.Appearance_ID in (Select M.ID_Matches from Matches M 
 where M.Player_ID = $player[0] and M.Match_ID = $match)",$connection);

 while($g=mysql_fetch_row($goal)) {
echo $g[0] .", ";
}

?>

Need Your Help

Android screen video record without root

android eclipse screen root record

I want to record a video of the entire screen of my android device and the free apps from google play that can do this require root. Can anyone help with specific steps of what can I do without roo...

How to set HTML Table column widths explicitly in JavaScript

javascript html table

I have hit a scaling problem with an HTML table, whilst manipulating it in JavaScript.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.