I have several DB queries that I know should be returning results and aren't. I have a feeling it has to do with the several while loops that should be outputting the data. One more issue is that when I echo the num_rows they are all 0 except the first one. BTW I checked that all variables were being populated and they were.
Here is my code:
Code: $sql1 = "SELECT * FROM player1 where player = '$username'"; $sql2 = "SELECT * FROM player2 where player = '$username'"; $sql3 = "SELECT * FROM player3 where player = '$username'"; $sql4 = "SELECT * FROM player4 where player = '$username'"; $sql5 = "SELECT * FROM player5 where player = '$username'"; $sql6 = "SELECT * FROM player6 where player = '$username'";
Code: while ($b < $num1){ $game=mysql_result($result1,$b,chatId); $g="SELECT * from chats where name = '$game'"; $gResult= mysql_query($g); $info=mysql_fetch_assoc($gResult); echo " <tr> <td>" . $info['realName'] . "</td> <td>" . $info['dm'] . "</td> </tr> "; $b++; } while ($b < $num2){ $game=mysql_result($result2,$b,chatId); $g="SELECT * from chats where name = '$game'"; $gResult= mysql_query($g); $info=mysql_fetch_assoc($gResult); echo " <tr> <td>" . $info['realName'] . "</td> <td>" . $info['dm'] . "</td> </tr> "; $b++; }
while ($b < $num3){ $game=mysql_result($result3,$b,chatId); $g="SELECT * from chats where name = '$game'"; $gResult= mysql_query($g); $info=mysql_fetch_assoc($gResult); echo " <tr> <td>" . $info['realName'] . "</td> <td>" . $info['dm'] . "</td> </tr> "; $b++; }
while ($b < $num4){ $game=mysql_result($result4,$b,chatId); $g="SELECT * from chats where name = '$game'"; $gResult= mysql_query($g); $info=mysql_fetch_assoc($gResult); echo " <tr> <td>" . $info['realName'] . "</td> <td>" . $info['dm'] . "</td> </tr> "; $b++; }
while ($b < $num5){ $game=mysql_result($result5,$b,chatId); $g="SELECT * from chats where name = '$game'"; $gResult= mysql_query($g); $info=mysql_fetch_assoc($gResult); echo " <tr> <td>" . $info['realName'] . "</td> <td>" . $info['dm'] . "</td> </tr> "; $b++; }
while ($b < $num6){ $game=mysql_result($result6,$b,chatId); $g="SELECT * from chats where name = '$game'"; $gResult= mysql_query($g); $info=mysql_fetch_assoc($gResult); echo " <tr> <td>" . $info['realName'] . "</td> <td>" . $info['dm'] . "</td> </tr> "; $b++; } I have tried changing the variable $b to something else in each loop but that didnt work either.