There is data in the database, which is displayed like this:
values1.php
<?php $con = mysql_connect("localhost","root","root"); if (!$con) die('Could not connect: ' . mysql_error()); mysql_select_db("test", $con); $data = mysql_query("SELECT UNIX_TIMESTAMP(`time`) AS ts, value FROM sensor1") or die ("Query error"); $V0 = ''; while($row = mysql_fetch_array($data, MYSQL_ASSOC)) { $V0 .= sprintf( ' %u %f', $row['ts'], $row['value']); } mysql_close($con); echo sprintf( '%s', strip_tags($V0)); ?> <?php On the website by the button the data is saved to a file. I am trying to implement through this PHP code, but in the downloaded file the code itself, and not the contents of the database.
<?php $file = 'values1.php'; if (isset($_GET['down'])) { if ($_GET['down'] == $file) { if (!is_file($file)) { echo "Файл <b>$file</b> не найден<br />\n"; } else { header("Content-Disposition: attachment; filename=$file"); header("Content-type: application/octet-stream"); $qwe = file_get_contents($file); echo $qwe; exit; } } else { echo "Файл $file не разрешен для скачивания<br>\n"; } } else { echo "<a href='?down=$file'> Скачать файл </a><br />\n"; } ?> Tell me how to save the data?