-1

I'm new at PHP, so if there's some kind of advice, it will be well received.

I want to concat all the results I get from a sql query to my database.

I got the code:

$sql = $_POST['sql']; /*sql query*/
$result = "";

$query = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($query, MYSQLI_NUM)) {
  $result = $result . ' ' . $row;
}

echo $result;

What I want is not a sql query that concats, but a way to concat rows with PHP.

1 Answers1

0

The correct syntax would be:

select group_concat(index separator ' ')
from playerdeck;

This assumes that you do not care about the ordering of the values. If you do:

select group_concat(index order by index separator ' ')
from playerdeck;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786