0
$get_top10 = mysqli_query($con, "SELECT name, daily_points, daily_win FROM players WHERE daily_points > 0 ORDER BY daily_points DESC LIMIT 10");

I am needing a string like: name, daily_points, daily_win, name, daily_points, daily_win (etc up to 10 records)

php 7.4.27 mysql 5.6.51-cll-lve

This did the trick, let me know if there is a better or preferred method.

$sql = ("SELECT name, daily_points, daily_win FROM players WHERE daily_points > 0 ORDER BY daily_points DESC LIMIT 10");
        $result = mysqli_query($con, $sql);

        if (mysqli_num_rows($result)) {
            while ($row = mysqli_fetch_assoc($result)) {
                echo "{$row['name']},{$row['daily_points']},{$row['daily_win']},";
            }
        }
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

1 Answers1

-1

you can try this code it will concatenate your php variable to html ',' and it's a preferred method

  $sql = ("SELECT name, daily_points, daily_win FROM players WHERE daily_points > 0 ORDER BY daily_points DESC LIMIT 10");
            $result = mysqli_query($con, $sql);
    
            if (mysqli_num_rows($result)) {
                while ($row = mysqli_fetch_assoc($result)) {
                     echo $row['name'].','.$row['daily_points'].','.$row['daily_win'];
                }
            }
Dotsquares
  • 755
  • 1
  • 2
  • 10