Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // database connection/retrieval code removed
- $sCSV = NULL;
- while($aRes = pg_fetch_assoc($rRes))
- {
- // first, middle, last, suffix, company, department,
- // title, bus. street, bus. city, bus. state, bus. zip,
- // bus. country, home street, home city, home state, home zip,
- // home country, bus. fax, bus. phone, bus. phone 2, home phone,
- // mobile phone, email
- // $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",
- $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",
- $aRes['sfirst'],
- !empty($aRes['smiddle1']) ? $aRes['smiddle1'] : "",
- $aRes['slast'],
- !empty($aRes['ssuffix']) ? $aRes['ssuffix'] : "",
- !empty($aRes['sprefix']) ? $aRes['sprefix'] : "",
- !empty($aRes['snick']) ? $aRes['snick'] : "",
- "Desert Research Institute",
- !empty($aRes['saffil']) ? $aRes['saffil'] : "",
- !empty($aRes['stitle1']) ? $aRes['stitle1'] : "",
- !empty($aRes['soffst1']) ? $aRes['soffst1'] : "",
- !empty($aRes['soffcity1']) ? $aRes['soffcity1'] : "",
- !empty($aRes['soffstate1']) ? $aRes['soffstate1'] : "",
- !empty($aRes['soffzip1']) ? $aRes['soffzip1'] : "",
- "United States of America",
- !empty($aRes['shome_streeta1']) ? $aRes['shome_streeta1'] : "",
- !empty($aRes['shome_city1']) ? $aRes['shome_city1'] : "",
- !empty($aRes['shome_state1']) ? $aRes['shome_state1'] : "",
- !empty($aRes['shome_zip1']) ? $aRes['shome_zip1'] : "",
- "United States of America",
- !empty($aRes['sofffax1']) ? $aRes['sofffax1'] : "",
- !empty($aRes['soffphone1']) ? $aRes['soffphone1'] : "",
- !empty($aRes['soffphone2']) ? $aRes['soffphone2'] : "",
- !empty($aRes['shome_phone1']) ? $aRes['shome_phone1'] : "",
- !empty($aRes['scell1']) ? $aRes['scell1'] : "",
- !empty($aRes['semail_dri']) ? $aRes['semail_dri'] : "",
- !empty($aRes['semail_alt']) ? $aRes['semail_alt'] : ""
- );
- }
- // for quick and dirty file creation do the following
- // php dump.php > dump.csv from the CLI
- printf("%s", $sCSV);
- ?>
Add Comment
Please, Sign In to add comment