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.

Menu