Sadece ilk giriş Echoing foreach

0 Cevap php

Ben iyi bilmeli, ama bu bir ile uzunca bir süre mücadele ettik eğer özür dilemek.

Ben 300 satır ile bir mysql db var. Bu 4 sütun, "Olay Kimliği", "player1", "player2", "puan" içeriyor. Oyunda, player1 bir puan 100 üzerinden çeşitli diğerleri (player2) verir.

Ne yapmaya çalışıyorum göstermek olduğunu kullanıcı (player1) onlar almışlardır "player2" s bir tablo kaydedilir.

Benim kod şöyle görünür:

$currentuserid = 00001;

$opponent_data = mysql_query("SELECT * FROM `scores` WHERE `player1` = $currentuserid ORDER by score");

$opponent_count = mysql_num_rows($opponent_data);

    echo $opponent_count.'<br>'; // Just to test -> and it shows I have 144entries in the array, i.e. 144player 2's that player 1 has scored

$opponent_scores = mysql_fetch_assoc($opponent_data);

$runrows = $opponent_scores;

foreach ($opponent_scores as &$runrows);

    {
    $id = $runrows['eventid'];
    $player2 = $runrows['player2'];
    $score = $runrows['score'];


    echo $player2." got ".$score;

    echo "<br>";

    }

Ben bu çalıştırdığınızda ben görebildiğim

144

73 var 44

but I was hoping to see 144rows of "player 2" got "player 2's score".

Ben yanlış ne yapıyorum?

0 Cevap