Save single row in DB, the result of the PHP variable (WHILE / LOOP) of a MYSQL Query

1

I have the following problem:

When performing a query, the result of the while is composed of more than one value, for example:

   $query_sku = mysqli_query($connect, "SELECT t.column_name
        FROM skus AS s
            INNER JOIN table AS t ON t.column_id = s.column_id
                WHERE s.id_sku = '{$id_sku}'");
WHILE($reg = mysqli_fetch_object($query_sku )){
  $variable = $reg->column_name;
echo "<br/">;
}

The result of this query / while is:

BATERIA  
PARA
CÂMERA
CANON
PowerShot ELPH 330 HS

And if I send it to the database, it will save one return per line:

WhenIactuallywantittoreturnthisway:

BATERIAPARACÂMERACANONPowerShotELPH330HS

AndsavetotheDatabaseinjustoneline:

    
asked by anonymous 04.01.2019 / 15:12

1 answer

0

If you change your code to the following, does it solve the problem?

while($reg = mysqli_fetch_object($query_sku ))
    $variable .= " ".$reg->column_name;

In the variable $variable is the concatenation of all the values of the query, where then just insert this value into the database.

    
04.01.2019 / 15:18