Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Email export: Whats wrong with this script?


NewBudda

Recommended Posts

Hi,

I am trying to export a list of all my customers witha dresses and email. Like this it works:

 

<?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 . " where 1");
  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();
?>

 

But it does not get the email adresses. When I try this:

 

<?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, customers_email_address FROM " . TABLE_ADDRESS_BOOK . " where 1");
  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']. ';' . $nempf['customers_email_address'] "\n";
  }
 header("Content-type: application/vnd.ms-excel");
 header("Content-disposition: attachment; filename=customers_postcode.csv");
 header("Expires: 0");
 echo $export;
 die();
?>

 

I just get a blank page. Why can't I get the email adresses too? What am I missing here?

 

Thank you for your input!

Open Source Newsletter: PhPList

Open Source Questionnaire: Lime Survey

Link to comment
Share on other sites

When I try this ... I just get a blank page.

 

The customers email address is not found in the address_book table. Hence the reason for the blank page - it is erroring out and not telling you what the error is.

 

The customers email address exists in the customers table: customers_email_address.

 

Hence you have to join the table together to get the info.

 

Try:

 

SELECT ab.entry_gender, ab.entry_firstname, ab.entry_lastname, ab.entry_street_address, ab.entry_postcode, ab.entry_city, c.customers_email_address FROM address_book ab, customers c

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...