J'ai adapté la contribution "customers_export" de façon a récupérer sur excel la liste des clients ainsi que leur Email. Tout marche nickel.
Maintenant je voudrais exporté UNIQUEMENT les clients inscripts a la newletter. (sous excel le trie n'est pas facile quand il y a plusieurs milliers de lignes)
Donc mon idée est de trier avant l'export . La table "customers" à un champ "newletter", valeur (0) quand pas inscript ou (1) quand inscript. Dans l'état actuel de mon script je récupère toute les valeures de ce champ.
Je ne suis pas encore assé compétant pour modifier la variable du script...
Code
<?php
require('includes/application_top.php');
if (!$HTTP_GET_VARS['submit'])
{
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//DE">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#CCCC33">
<!-- header //-->
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2" >
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td><td>
<!-- body_text //-->
<?php
echo "<font size= 2 face= Verdana, Arial, Helvetica, sans-serif >Exporter et sauvegarder la liste des noms et emails client sur Excel</font> ";
echo '<form action="'. $phpself.'">';
echo '<input type="submit" value="Exporter les infos clients" name="submit"></form>';
?>
</td>
</table>
<!-- footer //-->
<center><font color="#666666" size="2"></font></center>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php
}
else
{
$contents="Email,Newsletter\n";
$user_query = mysql_query('select c.*, adb.* from subscribers as c left join address_book as adb on c.subscribers_id = adb.customers_id');
while($row = mysql_fetch_array($user_query))
{
$contents.=$row[subscribers_email_address].",";
$contents.=$row[customers_newsletter]."\n";
}
Header("Content-Disposition: attachment; filename=export.csv");
print $contents;
}
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
require('includes/application_top.php');
if (!$HTTP_GET_VARS['submit'])
{
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//DE">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#CCCC33">
<!-- header //-->
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2" >
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td><td>
<!-- body_text //-->
<?php
echo "<font size= 2 face= Verdana, Arial, Helvetica, sans-serif >Exporter et sauvegarder la liste des noms et emails client sur Excel</font> ";
echo '<form action="'. $phpself.'">';
echo '<input type="submit" value="Exporter les infos clients" name="submit"></form>';
?>
</td>
</table>
<!-- footer //-->
<center><font color="#666666" size="2"></font></center>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php
}
else
{
$contents="Email,Newsletter\n";
$user_query = mysql_query('select c.*, adb.* from subscribers as c left join address_book as adb on c.subscribers_id = adb.customers_id');
while($row = mysql_fetch_array($user_query))
{
$contents.=$row[subscribers_email_address].",";
$contents.=$row[customers_newsletter]."\n";
}
Header("Content-Disposition: attachment; filename=export.csv");
print $contents;
}
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
Une idée ou une petite expliquation que je puisse bien comprendre la mécanique...
Merci
Alain