Dave thank you for taking the time and helping me
so this is my code now:
<?php
include_once('functions.php');
function mail_attachments ($to, $subject, $body, $attachments, $headerstr, $mailparams = FALSE)
{
$mixedboundary = 'boundary-mixed-'.($random_hash = md5(time()));
$bodystr = "--$mixedboundary\r\n";
if (isset($body['html']) && isset($body['text'])) {
$bodystr .= "Content-Type: multipart/alternative; boundary=\"".($altboundary = "boundary-alt-$random_hash")."\"\r\n\r\n--$altboundary\r\nContent-Type: text/plain; charset=\"iso-8859-1\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n".$body['text']."\r\n\r\n--$altboundary\r\nContent-Type: text/plain; charset=\"iso-8859-1\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n".$body['html']."\r\n\r\n--$altboundary--\r\n\r\n--$mixedboundary";
} else if (($html = isset($body['html'])) || isset($body['text'])) {
$bodystr .= "Content-Type: text/".(($html) ? 'html' : 'plain')."; charset=\"iso-8859-1\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n".(($html) ? $body['html'] : $body['text'])."\r\n\r\n--$mixedboundary";
} else return FALSE;
foreach ($attachments as $attachment => $type) if (is_file($attachment)) $bodystr .= "\r\nContent-Type: $type; name=\"".basename($attachment)."\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment\r\n\r\n".chunk_split(base64_encode(file_get_contents($attachment)))."\r\n--$mixedboundary";
$bodystr .= "--"; print($bodystr."\r\n\r\nHeaders:\r\n".$headerstr);
return ($mailparams) ? @mail($to,$subject,$bodystr,$headerstr,$mailparams) : @mail($to,$subject,$bodystr,$headerstr);
}
$todaydate = date("Y-m-d");
$usersquery = mysql_query("SELECT * FROM users") or die(mysql_error);
$usersnumber = mysql_num_rows($usersquery);
if ($usersnumber == 0)
{
echo "there are no users registered in this website";
}
else
{
$cardsoverall = mysql_query("SELECT * FROM cards") or die(mysql_error);
$cardsoverallnum = mysql_num_rows($cardsoverall);
$startnum = ($cardsoverallnum + 1);
echo "You have " . $usersnumber . " user(s)<br/>";
echo "You have " . $cardsoverallnum . " card(s)<br/>";
echo "Excel starting number is: " . $startnum . "<br/>";
echo "============================<br/>";
while($userarray = mysql_fetch_array($usersquery))
{
$name = $userarray['first'];
$email = '<html><body><strong>' . $name . ",</strong><br/><br/>" .
"<strong>Your cards have been processed, and added to your account.</strong><br/>" .
"<strong>Please sign into your 'Account Navigation' page. Please set the asking price(s) for your cards and view your account balance.</strong><br/><br/>" .
"<table rules='all' border='1' style='border-color: #666;' cellpadding='10'>" .
"<tr style='background: #eee;'><th><center><strong>Item Number</strong><center></th><th><center><strong>Description</strong></center></th></tr>";
$username = $userarray['username'];
echo $username . ": ";
$cards = mysql_query("SELECT * FROM cards WHERE title = '' AND seller = '$username'") or die("card finding error");
$cardsnumber = mysql_num_rows($cards);
if ($cardsnumber == 0)
{
echo "No new cards for this user<br/>";
}
else
{
$_file = 'Cardslist.csv';
$_fp = @fopen( $_file, 'w' );
$_csv_data= "Item Number" . "," . "Description" . "\n";
@fwrite( $_fp, $_csv_data );
while ($newcards = mysql_fetch_array($cards))
{
$cardid = $newcards['cardid'];
if ($newcards['sn'] != NULL)
$serialnum = " /" . $newcards['sn'];
else
$serialnum = '';
if ($newcards['cardnumber'] != NULL)
$title = $newcards['year'] . " " . $newcards['brand'] . " ". $newcards['setname'] . " #" . $newcards['cardnumber'] . " - " . $newcards['playername'] . $serialnum;
else
$title = $newcards['year'] . " " . $newcards['brand'] . " ". $newcards['setname'] . " - " . $newcards['playername'] . $serialnum;
$horizental = strtolower($newcards['horizontal']);
$backhorizental = strtolower($newcards['backhorizental']);
$seller = strtolower($newcards['seller']);
$updatecards = mysql_query("UPDATE cards SET title = '$title', horizontal = '$horizental', backhorizental = '$backhorizental', aday = '$todaydate', ava = 'yes', sold = 'no', send = 'no', shipping = 'no', seller = '$seller' WHERE cardid = '$cardid'") or die("changing information error");
if (!$updatecards)
{
echo "ERROR CARD " . $title . " with item number of " . $cardid . " had a problem!";
}
else
{
$email = $email . "<tr><td><center>" . $cardid . "</center></td><td><center>" . $title . "</center></td></tr>";
$_csv_data= $cardid . ',' . $title . "\n";
@fwrite( $_fp, $_csv_data );
}
}
$email = $email . "</table><br/><br/><strong>Your card processing receipt is attached in this email.<br/>If you have any comments, questions or concerns please feel free to contact us</strong>" .
"<br/><br/><strong>SCM</strong><br/>" . "<a href = 'http://www.scm.com'>scm.com</a>";
@fclose( $_fp );
$file = array ( '$_fp'=>'.SVC' );
$emailhtml = array ('html' => $email);
$useremail = $userarray['email'];
$headers = "From: sportscardmovers <no-reply@scm.com>" . "\r\n";
$headers .= "Reply-To: no-reply@scm.com" ."\r\n";
$headers .= 'Return-path: no-reply@scm.com' . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if ( mail_attachments($useremail, "Cards were added to your Account", $emailhtml, $file, $headers, "-fno-reply@scm.com"))
echo "E-mail was sent<br/>";
else
echo "error - e-mail didn't go through<br/>";
}
$getempty = mysql_query("SELECT * FROM cards") or die (mysql_error);
while ( $emptycard = mysql_fetch_array($getempty))
{
if ($emptycard['cardid'] == 0 && $emptycard['title'] == "" && $emptycard['playername'] == "")
{
$deletecards = mysql_query("DELETE FROM cards WHERE cardid = 0") or die(mysql_error);
}
}
}
}
?>
this is my out put!
You have 1 user(s)
You have 69 card(s)
Excel starting number is: 70
============================
admin: --boundary-mixed-bc86e9a6529644995d8497331fb77106 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit farshad,
Your cards have been processed, and added to your account.
Please sign into your 'Account Navigation' page. Please set the asking price(s) for your cards and view your account balance.
Item Number
Description
69
2007 Playoff Absolute Memorabilia Rookie Premiere Materials Autograph AFC/NFC #269 - Kenny Irons /25
Your card processing receipt is attached in this email.
If you have any comments, questions or concerns please feel free to contact us
SCM
scm.com --boundary-mixed-bc86e9a6529644995d8497331fb77106-- Headers: From: scm Reply-To: no-reply@scm.com Return-path: no-reply@scm.com MIME-Version: 1.0 Content-Type: text/html; charset=ISO-8859-1 E-mail was sent
and email i get is:
--boundary-mixed-bc86e9a6529644995d8497331fb77106 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit
farshad,
Your cards have been processed, and added to your account.
Please sign into your 'Account Navigation' page. Please set the asking price(s) for your cards and view your account balance.
Item Number
Description
69
2007 Playoff Absolute Memorabilia Rookie Premiere Materials Autograph AFC/NFC #269 - Kenny Irons /25
Your card processing receipt is attached in this email.
If you have any comments, questions or concerns please feel free to contact us
SCM
scm.com --boundary-mixed-bc86e9a6529644995d8497331fb77106-
and nothing is attached to the email! 🙁