Arrange the names and commas from the data

$product_name = $pdo->query(
       "SELECT * FROM `stock` as s
       JOIN `product` as p ON p.prod_id = s.prod_id
       WHERE s.order_id = "{$first_order["order_id"]}" "
     );
     $productNameArray = null;
     while ($row = mysqli_fetch_array($product_name)){
       $productNameArray[] = $row["name"];
     }

in this way, I can export all the names to array.
how can I arrange him with name 1, name 2, name 3. ? And then apply this data to a certain global variable?

Mar.30,2021

do you mean implode (',', $productNameArray) ?
or you can solve

directly through SQL.
  https://www.cnblogs.com/Striv.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36871-2c034.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36871-2c034.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?