Jump to content

Recommended Posts

Hi guys can anyone please help me? I have to run a script that generates a report into an excel document then emails the document simultaneous to the user with the spreadsheet attached! Although it needs to write a document for each users specific details in the database and mail that user his specific spreadsheet with his details in! Heres a sample of what im trying to do.

 

require_once 'Spreadsheet/Excel/Writer.php';

 

$sql = "select distinct agent from leads";

$qry = mysql_query($sql, $conn);

 

$workbook = new Spreadsheet_Excel_Writer();

 

$workbook->send('liveleads.xls');

 

$worksheet =& $workbook->addWorksheet(liveleads);

 

$worksheet->write(0, 0, 'agent');

$worksheet->write(0, 1, 'leadID'); // all leads for that agent

$worksheet->write(0, 2, 'contactperson'); // all contacts that agent has

 

while($array = mysql_fetch_array($qry)) {

$i = 1;

$sql2 = "select * from leads where agent = $array[agent]";

$qry2 = mysql_query($sql2, $conn);

     

        while($array2 = mysql_fetch_array($qry2)){

              $worksheet->write($i, 0, $array[agent]);

              $worksheet->write($i, 1, $array[leadID]);

              $worksheet->write($i, 2, $array[contactperson]);

              $i++;

 

 

        }

mail($array,"subject"etc.......");

}

$workbook->close();

 

#so basically i need to loop through the agents get the leads that belong to the specific agent

#then write an excel document for each agent listing his specific leads

#then mail each agent with his specific document attached containing his leads while the script runs

 

#Any help will be greatly appreciated :)

 

 

Link to comment
https://forums.phpfreaks.com/topic/64042-advanced-email-excel-spreadsheet-writer/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.