tomz0r Posted September 11, 2010 Share Posted September 11, 2010 Hello, I am having some trouble with calling certain array values while a condition equals something. I have called values from a database table into an array: $result = mysql_query("SELECT `TeamID`, `ScoreA`, `ScoreB`,`TeamPlayed`, `RoundNum` FROM `scores` WHERE `CompID` = 4 ORDER BY `RoundNum` ASC") or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { print_r($row); } Array ( [TeamID] => 3 [scoreA] => 16 [scoreB] => 4 [TeamPlayed] => 4 [RoundNum] => 1 ) Array ( [TeamID] => 1 [scoreA] => 16 [scoreB] => 1 [TeamPlayed] => 6 [RoundNum] => 1 ) Array ( [TeamID] => 2 [scoreA] => 16 [scoreB] => 14 [TeamPlayed] => 5 [RoundNum] => 1 ) Array ( [TeamID] => 4 [scoreA] => 16 [scoreB] => 0 [TeamPlayed] => 6 [RoundNum] => 2 ) Array ( [TeamID] => 1 [scoreA] => 10 [scoreB] => 16 [TeamPlayed] => 2 [RoundNum] => 2 ) Array ( [TeamID] => 5 [scoreA] => 14 [scoreB] => 16 [TeamPlayed] => 3 [RoundNum] => 2 ) From here I want to able to get display certain values while RoundNum = $value So while RoundNum = 1 display the array values of: TeamID V TeamPlayed ScoreA - ScoreB Hope you can decipher what I am asking, don't think I have worded it very well :S. Thanks for anyhelp! Quote Link to comment https://forums.phpfreaks.com/topic/213124-calling-array-values/ Share on other sites More sharing options...
jcbones Posted September 11, 2010 Share Posted September 11, 2010 replace print_r($row); With: if($row['RoundNum'] == 1) { echo '<table><tr><td>' . $row['TeamID'] . '</td><td> VS </td><td>' . $row['TeamPlayed'] . "</td></tr>\n" .'<tr><td>' . $row['ScoreA'] . '</td><td> </td><td>' . $row['ScoreB'] . "</td></tr>\n</table>"; } Quote Link to comment https://forums.phpfreaks.com/topic/213124-calling-array-values/#findComment-1109898 Share on other sites More sharing options...
tomz0r Posted September 11, 2010 Author Share Posted September 11, 2010 THANK YOU! <3 Quote Link to comment https://forums.phpfreaks.com/topic/213124-calling-array-values/#findComment-1109904 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.