Ciao ragazzi dovrei creare un file xls tramite una query e infatti ci sono riuscito tramite questo script:
Il problema è che mi chiedi di salvare manualmente il file xls che tra l'altro è stato compilato adhoc con i campi da me richiesti..codice:<?php $manufacturers_id="6"; //connessione DB $filename="export.xls"; header ("Content-Type: application/vnd.ms-excel"); header ("Content-Disposition: inline; filename=$filename"); ?> <html><head><title>Export</title></head><body> <table border="1"> <tr> <th>Quantità</th> <th>Codice Articolo</th> <th>Variabile 1</th> <th>Variabile 2</th> </tr> <? $risultato_query = mysql_query("SELECT * FROM tabella WHERE prodotto_id = '{$prodotto_id}'"); while ($row=mysql_fetch_array($risultato_query)) { ?> <tr> <td><? echo $row['quantita_ordine']; ?></td> <td><? echo $row['products_codice']; ?></td> <td><? echo $row['products_attributo1var']; ?></td> <td><? echo $row['products_attributo2var']; ?></td> </tr> <? } ?> </table> </body></html> <? @mysql_close($connessione); ?> // START parte di codice per l'invio della mail.. / ASSEGNIAMO A VARIABILI PIU' LEGGIBILI, LE PROPRIETA' DELL'ALLEGATO $attach = $filename["tmp_name"]; $file_name = $filename["name"]; $file_type = $filename["type"]; $file_size = $filename["size"]; // DELIMITATORE $boundary = md5(uniqid(microtime())); // APRIAMO L'ALLEGATO PER LEGGERLO E CODIFICARLO $file = @fopen($attach, "r"); $contents = @fread($file, $file_size); $encoded_attach = chunk_split(base64_encode($contents)); @fclose($file); // INTESTAZIONI DELLA MAIL $mail_headers .= "MIME-version: 1.0\n"; $mail_headers .= "Content-type: multipart/mixed; boundary=\"$boundary\""; $mail_headers .= "X-attachments: $file_name\n"; //Creo GLI altri campi per la mail $Destinatario, $Soggetto, $mail_body .................................. ................................. ................................. // INVIO DELLA MAIL mail($Destinatario, $Soggetto, $mail_body, $mail_headers)
Ma io invece vorrei far si che anzichè chiedermi di salvarlo, me lo alleggasse alla mail, quindi me lo "passasse" ($filename) alla parte di codice piu in basso che per l'appunto mi genera la mail e me la invia..
Come posso fare?
Grazie a tutti!

Rispondi quotando
