2

I am trying to make a leaderboard and sort my data by kills, but when I try to make it so it only grabs name, kill, death it doesnt grab anything but when I have it grab it all it works. Anyone know why? Code is below please assist.

<?php
                    $query = $koneksi->prepare("SELECT * from `player`");
                    $query->execute();
                    if($query->rowCount() == 0)

I am grabbing my mysql data here, if I change the * to the data I need no data is displayed.

                        echo "<tr><td colspan='6'><small>There's no player on ban list</small></td></tr>";
                    }
                    while($data = $query->fetch())
                    {
                        echo "<tr><td>".$data['name']."</td>";
                        echo "<td>".$data['kill']."</td>";
                        echo "<td>".$data['death']."</td>";
                        $kd = $data['kill'] / $data['death'];
                        echo "<td>".$kd."</td></tr>";
                    }
                    ?>

Is it something to do with this or is something wrong? I am really confused.

ZiiM
  • 31
  • 1
  • 6

1 Answers1

0

Here you have to use bind_result() and in that you have to pass the number of parameters which is equal to your number of field from your player table.
Because here you are fetching data using select * query.

milan kyada
  • 579
  • 5
  • 15