NewBudda Posted October 7, 2009 Posted October 7, 2009 How do I get a list of all my registered customers sorted by the post code? Is there a contribution for it or a script? Is it possible to alter this script to export all the customers? <?php require('includes/application_top.php'); $export = ''; $query = tep_db_query("SELECT customers_firstname, customers_lastname, customers_email_address FROM " . TABLE_CUSTOMERS . " WHERE customers_newsletter = 1"); while($nempf = tep_db_fetch_array($query)) { $export .= $nempf['customers_firstname']. ';' . $nempf['customers_lastname']. ';' . $nempf['customers_email_address'] . "\n"; } header("Content-type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=customers_newsletters.csv"); header("Expires: 0"); echo $export; die(); ?> Where can I learn how to do that, so in the future I can help myself? Thank you for your help! Open Source Newsletter: PhPList Open Source Questionnaire: Lime Survey
Guest Posted October 7, 2009 Posted October 7, 2009 If you install 'Customers List Improved' You can sort by name, address, DOB, Country, Last Log in etc......I am sure you can easily adapt it to call the postal code into the list and sort it using the code already in place. Chris
NewBudda Posted October 7, 2009 Author Posted October 7, 2009 OK, I found: customers_firstname, customers_lastname, customers_email_address FROM " . TABLE_CUSTOMERS in phpmyadmin. And I can add customers_gender and customers_telephone but I can not find "customer_postcode" There is entry_postcode in the address_book table but i don't know how to get the postcode for each customer... Help? Open Source Newsletter: PhPList Open Source Questionnaire: Lime Survey
NewBudda Posted October 7, 2009 Author Posted October 7, 2009 Whats wrong with this? I get a "Parse error: parse error, unexpected ')' on line 5: <?php require('includes/application_top.php'); $export = ''; $query = tep_db_query("SELECT entry_gender, entry_firstname, entry_lastname, entry_street_address, entry_postcode, entry_city FROM " . TABLE_ADDRESS_BOOK . ); while($nempf = tep_db_fetch_array($query)) { $export .= $nempf['entry_gender']. ';' . $nempf['entry_firstname']. ';' . $nempf['entry_lastname']. ';' . $nempf['entry_street_address']. ';' . $nempf['entry_postcode']. ';' . $nempf['entry_city']. "\n"; } header("Content-type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=customers_postcode.csv"); header("Expires: 0"); echo $export; die(); ?> There is no ')' on line 5. Whats wrong? Open Source Newsletter: PhPList Open Source Questionnaire: Lime Survey
l_s_l_s Posted October 7, 2009 Posted October 7, 2009 $query = tep_db_query("SELECT entry_gender, entry_firstname, entry_lastname, entry_street_address, entry_postcode, entry_city FROM " . TABLE_ADDRESS_BOOK . ); while($nempf = tep_db_fetch_array($query)) { ------------ The ')' is at the end of the line 5
NewBudda Posted October 7, 2009 Author Posted October 7, 2009 $query = tep_db_query("SELECT entry_gender, entry_firstname, entry_lastname, entry_street_address, entry_postcode, entry_city FROM " . TABLE_ADDRESS_BOOK . ); while($nempf = tep_db_fetch_array($query)) { ------------ The ')' is at the end of the line 5 Sorry but which ) is the problem? I just don't see it... Edit: I know removed every ) one by one and I only end up getting different erro messages :( Open Source Newsletter: PhPList Open Source Questionnaire: Lime Survey
NewBudda Posted October 7, 2009 Author Posted October 7, 2009 I changed the following (working) code: $query = tep_db_query("SELECT customers_firstname, customers_lastname, customers_email_address FROM " . TABLE_CUSTOMERS . " WHERE customers_newsletter = 1"); while($nempf = tep_db_fetch_array($query)) { $export .= $nempf['customers_firstname']. ';' . $nempf['customers_lastname']. ';' . $nempf['customers_email_address'] . "\n"; } into this: $query = tep_db_query("SELECT entry_gender, entry_firstname, entry_lastname, entry_street_address, entry_postcode, entry_city FROM " . TABLE_ADDRESS_BOOK . ); while($nempf = tep_db_fetch_array($query)) { $export .= $nempf['entry_gender']. ';' . $nempf['entry_firstname']. ';' . $nempf['entry_lastname']. ';' . $nempf['entry_street_address']. ';' . $nempf['entry_postcode']. ';' . $nempf['entry_city']. "\n"; } I left the "WHERE customers" thing out, because I wanted all customers to be selected. I also changed the table the information is grabbed from. But I still get the same error message. Whats wrong? Open Source Newsletter: PhPList Open Source Questionnaire: Lime Survey
Recommended Posts
Archived
This topic is now archived and is closed to further replies.