Esempio n. 1
0
 }
 $result = mysql_query($sql);
 if (mysql_error()) {
     trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING);
 }
 $html .= "<p align='center'><code>{$sql}</code></p>\n";
 $html .= "<table width='100%'>";
 $html .= $htmlfieldheaders;
 $shade = 'shade1';
 while ($row = mysql_fetch_row($result)) {
     $columns = count($row);
     $html .= "<tr class='{$shade}'>";
     $csv .= "\"";
     for ($i = 0; $i < $columns; $i++) {
         $html .= "<td>{$row[$i]}</td>";
         $csv .= strip_comma($row[$i]);
         if ($i < $columns - 1) {
             $csv .= '","';
         }
     }
     $html .= "</tr>\n";
     if ($shade == 'shade1') {
         $shade = 'shade2';
     } else {
         $shade = 'shade1';
     }
     $csv .= "\"\r\n";
 }
 $html .= "</table>";
 if ($_POST['output'] == 'screen') {
     include APPLICATION_INCPATH . 'htmlheader.inc.php';
         if (mysql_error()) {
             trigger_error(mysql_error(), E_USER_WARNING);
         }
         $numproducts = mysql_num_rows($presult);
         $productcount = 1;
         while ($product = mysql_fetch_object($presult)) {
             $html .= strip_comma($product->name);
             $csv .= strip_comma($product->name);
             if ($productcount < $numproducts) {
                 $html .= " - ";
                 $csv .= ' - ';
             }
             $productcount++;
         }
         $html .= "</td>";
         $csv .= strip_comma($row->name) . "\"\r\n";
         $rowcount++;
     }
     $lastemail = $row->contactemail;
 }
 $html .= "</table>";
 $html .= "<p align='center'>" . sprintf($strShowingXofX, $rowcount, $numrows) . "</p>";
 //$html .= "<p align='center'>SQL Query used to produce this report:<br /><code>$sql</code></p>\n";
 if ($_REQUEST['output'] == 'screen') {
     include APPLICATION_INCPATH . 'htmlheader.inc.php';
     echo "<h2>{$strMarketingMailshot}</h2>";
     echo "<p align='center'>{$strMarketingMailshotDesc}</p>";
     echo $html;
     include APPLICATION_INCPATH . 'htmlfooter.inc.php';
 } elseif ($_REQUEST['output'] == 'csv') {
     // --- CSV File HTTP Header
     //                 echo $prodsql;
     $prodresult = mysql_query($prodsql);
     if (mysql_error()) {
         trigger_error('!Error: MySQL Query Error:', mysql_error(), E_USER_WARNING);
     }
     if (mysql_num_rows($prodresult) > 0) {
         $numofproducts = mysql_num_rows($prodresult);
         while ($siteproducts = mysql_fetch_array($prodresult)) {
             $supportedproduct[$site['siteid']][$siteproducts['productid']] = $siteproducts['product'];
         }
     }
     // products list
     foreach ($product as $prodid => $prodname) {
         if (array_key_exists($prodid, $supportedproduct[$site['siteid']])) {
             $html .= "<td>{$prodname}</td>";
             $csv .= "\",\"" . strip_comma($prodname);
         } else {
             $html .= "<td></td>";
             $csv .= "\",\"";
         }
     }
     $html .= "</tr>\n";
     $csv .= "\"\n";
 }
 $html .= "</table>";
 mysql_free_result($result);
 // Print Headers
 if ($output == 'csv') {
     header("Content-type: text/csv\r\n");
     //header(\"Content-length: $fsize\\r\\n\");
     header("Content-disposition-type: attachment\r\n");