G
G
GRO242019-10-20 17:02:09
PHP
GRO24, 2019-10-20 17:02:09

Writing a loop to a variable?

Hello. I'm trying to write the output from the database to a variable.
In a DB about 30 lines and 10 columns, I want to write down all variables in one and to write down in a file
But, in the current result writes down only the last line.

$result = mysqli_query($link, "SELECT * FROM `table`");
    while($result_show = mysqli_fetch_array($result)){ 

        $symbol = $result_show['symbol'];


        $data = '

       Перменная1: '.$symbol.'

        ';
    file_put_contents($file, $data);
        echo $data;
  }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Terekhin, 2018-08-08
@RomaZveR

Страшный конечно запрос. Не делайте так никогда, используйте PDO и биндинги.
Покажите структуру таблицы, тип и кодировку поля url, набор данных для примера и содержимое $url

M
mahmudchon, 2019-10-20
@GRO24

file_put_contents($file, $data, FILE_APPEND);
"If the file filename already exists, the data will be appended to the end of the file instead of being overwritten."
https://www.php.net/manual/ru/function.file-put-co...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question