i am trying to make a program that syncs all the outcome of a row in my mysql database to a .txt file. But it doesnt work. I want each result on a new line.
This is my code:
<?php
$db = mysqli_connect("localhost", "username", "pass", "database");
$hwid_query = "SELECT hwid FROM users";
$result = mysqli_query($db, $hwid_query);
//$hwids = mysqli_fetch_assoc($result);
while($row = mysqli_fetch_assoc($result)){
$hwids = $row['hwid'];
echo $hwids;
}
$fp = fopen('lt.txt', 'w');
ftruncate($fp, 0);
fwrite($fp, $hwids);
fclose($fp);
mysqli_close($db);
?>
This results in one line in the file with only one of the columns of the database, while echo $hwids;
gives all of them. What am i doing wrong?