Guest User

Untitled

a guest
Sep 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. <?php
  2. // database connection/retrieval code removed
  3.  
  4. $sCSV = NULL;
  5.  
  6. while($aRes = pg_fetch_assoc($rRes))
  7. {
  8.  
  9. // first, middle, last, suffix, company, department,
  10. // title, bus. street, bus. city, bus. state, bus. zip,
  11. // bus. country, home street, home city, home state, home zip,
  12. // home country, bus. fax, bus. phone, bus. phone 2, home phone,
  13. // mobile phone, email
  14. // $sCSV .= sprintf("'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s'\n",
  15. $sCSV .= sprintf("\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n",
  16. $aRes['sfirst'],
  17. !empty($aRes['smiddle1']) ? $aRes['smiddle1'] : "",
  18. $aRes['slast'],
  19. !empty($aRes['ssuffix']) ? $aRes['ssuffix'] : "",
  20. !empty($aRes['sprefix']) ? $aRes['sprefix'] : "",
  21. !empty($aRes['snick']) ? $aRes['snick'] : "",
  22. "Desert Research Institute",
  23. !empty($aRes['saffil']) ? $aRes['saffil'] : "",
  24. !empty($aRes['stitle1']) ? $aRes['stitle1'] : "",
  25. !empty($aRes['soffst1']) ? $aRes['soffst1'] : "",
  26. !empty($aRes['soffcity1']) ? $aRes['soffcity1'] : "",
  27. !empty($aRes['soffstate1']) ? $aRes['soffstate1'] : "",
  28. !empty($aRes['soffzip1']) ? $aRes['soffzip1'] : "",
  29. "United States of America",
  30. !empty($aRes['shome_streeta1']) ? $aRes['shome_streeta1'] : "",
  31. !empty($aRes['shome_city1']) ? $aRes['shome_city1'] : "",
  32. !empty($aRes['shome_state1']) ? $aRes['shome_state1'] : "",
  33. !empty($aRes['shome_zip1']) ? $aRes['shome_zip1'] : "",
  34. "United States of America",
  35. !empty($aRes['sofffax1']) ? $aRes['sofffax1'] : "",
  36. !empty($aRes['soffphone1']) ? $aRes['soffphone1'] : "",
  37. !empty($aRes['soffphone2']) ? $aRes['soffphone2'] : "",
  38. !empty($aRes['shome_phone1']) ? $aRes['shome_phone1'] : "",
  39. !empty($aRes['scell1']) ? $aRes['scell1'] : "",
  40. !empty($aRes['semail_dri']) ? $aRes['semail_dri'] : "",
  41. !empty($aRes['semail_alt']) ? $aRes['semail_alt'] : ""
  42. );
  43. }
  44.  
  45.  
  46. // for quick and dirty file creation do the following
  47. // php dump.php > dump.csv from the CLI
  48. printf("%s", $sCSV);
  49.  
  50. ?>
Add Comment
Please, Sign In to add comment