Jump to content

Recommended Posts

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!

 

Link to comment
https://forums.phpfreaks.com/topic/213124-calling-array-values/
Share on other sites

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>";
}

       

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.