userVw.php 804 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. require "connectionDb.php";
  3. $suppliers = $db->query("SELECT * FROM user");
  4. $json_data=[];
  5. while ($row = $suppliers->fetchArray()) {
  6. //print_r($row);
  7. $details = [
  8. "Id" => $row['id'],
  9. "Name" => $row['name'],
  10. "Email" => $row['email'],
  11. "Password" => $row['password'],
  12. "Activation_Token" => $row['activation_token'],
  13. "Password_Reset_Token" => $row['password_reset_token'],
  14. "Join_Token" => $row['join_token'],
  15. "Role" => $row['role'],
  16. "Pass_Code" => $row['pass_code'],
  17. "Pump_List" => $row['pump_list'],
  18. ];
  19. //here pushing the values in to an array
  20. array_push($json_data,$details);
  21. }
  22. $json_data_all = ["data" => $json_data];
  23. $myfile = fopen("api/v1/Users/users.txt", "w+") or die("Unable to open file!");;
  24. fwrite($myfile,json_encode($json_data_all, JSON_PRETTY_PRINT));
  25. fclose($myfile);
  26. ?>