I'm trying to run this MySQL code in PHP.
SELECT DISTINCT teamid FROM teammembers INNER JOIN teams WHERE teams.id = teammembers.teamid
If I run this code in SQL, I get around 20 different values, and I would like to save this unique values in an array so I can use them later.
So I'm using this PHP code:
$totalteams = mysql_query("SELECT DISTINCT teamid FROM teammembers INNER JOIN teams WHERE teams.id = teammembers.teamid");
Now I want to check if the code is working or not, so I did:
echo $totalteams;
And as result I got:
Resource id #5
I also tried with:
echo mysql_result($totalteams,0);
And it does work that way, but that count asks me for the row number, therefore it only displays one value, and I need all of them.
Can anyone help me?
while ($row = mysql_fetch_assoc( $totalteams )) {
print_r( $row );
}