Bad Credit Loan - Actress - Super Mario Games - Moneygram - eBay

PDA

View Full Version : LAST! Email program... PHP(/MySQL) work


cowguru2000
Mar 6th 2007, 1:25 pm
Wow! Well, I've got to say, everybody in this forum helped me and I've come a loooooong way with PHP, MySQL, and my email program.

Now, I set up this realllllly confusing loop that actually got my email program to work!... most of the way.

Before I say anything else, here's my PHP code:


<?php
/* File: email.inc
* Desc: Emails the shopper and orders@jogrammah.com.
*/

$connect = connect_to_db("Vars.inc");

$query = 'SELECT * FROM order_item WHERE order_number = "' . mysql_real_escape_string($_SESSION['order_number']) . '"';

$result = mysql_query($query)
or die("sql_email: ".mysql_error());

$numrows = mysql_num_rows($result);

$ordernumber = $_SESSION['order_number'];

if ($numrows) {
$itemsmessage = "You ordered:\n\n";
while ($row = mysql_fetch_assoc($result)) {

$query2 = 'SELECT catalog_number FROM order_item WHERE order_number = "' . mysql_real_escape_string($_SESSION['order_number']) . '"';

$result2 = mysql_query($query2)
or die ("sql_email2: ".mysql_error());

while ($rows2 = mysql_fetch_assoc($result2)) {

$query3 = 'SELECT name FROM Food WHERE catalog_number = "' . $rows2['catalog_number'] . '"';

$result3 = mysql_query($query3)
or die("sql_email3: ".mysql_error());

while ($rw = mysql_fetch_array($result3)) {
$blah = $rw['name'];
/* echo $rw['name'];
echo "<br>"; */
}
}

$itemsmessage = $itemsmessage . "Item number " . $row['item_number'] . ":" . " Item name: '" . $blah . "' | qty: " . $row['quantity'] . "\n";
}
};

$emailto = $_SESSION['email'];
$orderID = $_SESSION['order_number'];
$subject = "Your order number ".$_SESSION['order_number']." -- JoGrammah.com";
$from = "From: orders@jogrammah.com";
$from2 = "From: ".$emailto;

$ship_name = $_SESSION['ship_name'];
$ship_street = $_SESSION['ship_street'];
$ship_city = $_SESSION['ship_city'];
$state = $_SESSION['ship_state'];
$ship_zip = $_SESSION['ship_zip'];
$phone = $_SESSION['phone'];
$cc_number = $_SESSION['cc_number'];
$ordertotal = $_SESSION['order_total'];
$noitemsordered = $_SESSION['n_items'];

$subject2 = "Order # ".$_SESSION['order_number'].": ".$_SESSION['ship_name'];

$message = "Thank you for ordering at JoGrammah.com!\n
You ordered $noitemsordered item(s).
Your order costs "."$"."$ordertotal.
$itemsmessage
\nYour order will be shipped to:\n\n$ship_name\n$ship_street\n$ship_city, $state\n$ship_zip\n\nSince our store is not fully completed, you may be contacted at $phone for further details concerning your order.\n\nSincerely,\n-JoGrammah.com staff";


$message2 = "ORDER NUMBER $orderID \n\nShip to:\n$ship_name\n$ship_street\n$ship_city, $ship_state\n\nPhone number: $phone\nEmail: $emailto";

mail($emailto, $subject, $message, $from);

mail("orders@jogrammah.com", $subject2, $message2, $from2);

?>


Now, there's a slight problem. Look at the email it sent me.


Thank you for ordering at JoGrammah.com!

You ordered 4 item(s).
Your order costs $21.2.
You ordered:

Item number 1: Item name: 'Peppermint Swirl' | qty: 1.00
Item number 2: Item name: 'Peppermint Swirl' | qty: 2.00
Item number 3: Item name: 'Peppermint Swirl' | qty: 3.00
Item number 4: Item name: 'Peppermint Swirl' | qty: 4.00


Your order will be shipped to:

Bob Schmoe
123 Fake St.
Somewhere, AL
12345

Since our store is not fully completed, you may be contacted at 123-456-7890 for further details concerning your order.

Sincerely,
-JoGrammah.com staff


Now, this is excellent!...except for the fact that I didn't order a total of 10 'Peppermint Swirls'. Everything's right, except it just keeps repeating the 'Peppermint Swirl', which is only the first item I "bought"!

This is the last thing I want to do with my email program. It would be SO AWESOME if someone could PLEASE help me!

TIA,
-Joe

cowguru2000
Mar 6th 2007, 2:03 pm
uh, can somebody help me?

cowguru2000
Mar 6th 2007, 6:17 pm
NEVERMIND!

I figured it out myself!

YES!!!