a litle help with php code

Discussion in 'PHP' started by Kyriakos, Sep 1, 2008.

  1. #1
    hi,

    i have a php code and i sent an automatically e-mail when the customer is checkout his order. my problem is this

    $name = "";
    $email = "info@deftec.gr";
    $recipient = $_POST["mail"];
    while ($cart_r = mysql_fetch_assoc($cart_prods))
    {
    $mail_body = "Model: $model
    Quantity: $qty
    ---------------------------------------------------\n
    
    Pay amount: ".$_SESSION["mylimit"]." €";
    }
    $subject = "Defensive Technologies: automatic message"; //subject
    $header = "From: " . $email . "\r\n"; //optional headerfields
    
    mail($recipient, $subject, $mail_body, $header);
    PHP:
    i want to multiply the "Model" and "Quantity" for each product (record). how i can do this?
     
    Kyriakos, Sep 1, 2008 IP
  2. Ilyes

    Ilyes Banned

    Messages:
    129
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you please tell me what and how you want them to be multiplied ?
    Do you mean quantity = quantity * 2 ? Or something like that ?
     
    Ilyes, Sep 1, 2008 IP
  3. tsoft

    tsoft Active Member

    Messages:
    609
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Are you sure you want to multiply the "Model" and the "Quantity"? Or is it the "Amount" and Quantity???
     
    tsoft, Sep 1, 2008 IP
  4. Kyriakos

    Kyriakos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4
    i want exactly this think:

    Model: Geforce FX5500
    Quantity: 2
    ----------------------------------

    Model: ATI Radeon 7000
    Quantity: 1
    ---------------------------------

    Model: Core 2 Duo
    Quantity: 3
    --------------------------------

    for each record i want a new row just like that. do you anderstant now?
     
    Kyriakos, Sep 1, 2008 IP
  5. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Can you give the breakdown of your mysql table for the orders
     
    JAY6390, Sep 1, 2008 IP
  6. Kyriakos

    Kyriakos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #6
    <?php
    if ($checkout == "yes") {
    //update στοιχείων πελάτη στο clients
    mysql_query("UPDATE clients SET onoma='$_POST[onoma]', eponimo='$_POST[eponimo]', address='$_POST[address]', city='$_POST[city]', tk='$_POST[tk]', phone='$_POST[phone]', kinito='$_POST[kinito]', mail='$_POST[mail]', username='$_POST[username]', password='$_POST[password]', teponimia='$_POST[teponimia]', toccupation='$_POST[toccupation]', taddress='$_POST[taddress]', tafm='$_POST[tafm]', tdoy='$_POST[tdoy]', tphone='$_POST[tphone]' WHERE id='$_POST[id]'");
    
    //insert των στοιχείων της παραγγελίας στο header
    $sql = "INSERT INTO header (onoma, eponimo, address, city, tk, phone, kinito, mail, pliromi, tpliromi, apostoli, remarks, ordate, sessionid)
    VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')";
    
    $sqlRes = mysql_query(sprintf($sql,$_POST['onoma'],$_POST['eponimo'],$_POST['address'],$_POST['city'],$_POST['tk'],$_POST['phone'],$_POST['kinito'],$_POST['mail'],$_POST['pliromi'],$_POST['tpliromi'],$_POST['apostoli'],$_POST['remarks'],$_POST['ordate'],$sessionid),$con);
    
    //select του orderid της παραγγελίας απ'το header
    $query_id = mysql_query("SELECT orderid FROM header WHERE sessionid='$sessionid' ORDER BY orderid desc LIMIT 0, 1");
    $query_r = mysql_fetch_assoc($query_id);
    $orderid = $query_r['orderid'];
    
    //select των προϊόντων απ'το προσωρινο cart
    $cart_prods =  mysql_query("SELECT code, model, qty FROM cart WHERE sessionid='$sessionid' ORDER BY model");
    //insert των προϊόντων στο details
    while ($cart_r = mysql_fetch_assoc($cart_prods))
    {
    $code = $cart_r['code'];
    $model = $cart_r['model'];
    $qty = $cart_r['qty'];
    mysql_query("INSERT INTO details (orderid, code, model, qty) VALUES ('$orderid', '$code', '$model', '$qty')");
    
    echo "<div style=\"padding-left:15; padding-top:4;\" class=\"style5\"><b>Είδος</b>&nbsp;&nbsp;&nbsp;<font style=\"font-size:7px; font-family:Verdana;\">&nbsp;&nbsp;</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: $model <br><b>Ποσότητα </b>: $qty <br>----------------------------------------------------------------------------<br></div>\n";
    }
    $Name = ""; //senders name
    $email = "info@deftec.gr"; //senders e-mail adress
    $recipient = $_POST["mail"]; //recipient
    $mail_body = "Είδος: $model
    Ποσότητα: $qty
    ---------------------------------------------------\n
    
    Ποσό πληρωμής: ".$_SESSION["mylimit"]." €";
    $subject = "Defensive Technologies: automatic message"; //subject
    $header = "From: " . $email . "\r\n"; //optional headerfields
    
    mail($recipient, $subject, $mail_body, $header);
    
    $sqlDel = "DELETE FROM cart WHERE sessionid='$sessionid'";
    mysql_query($sqlDel, $con); 
    
    echo "<div style=\"padding-left:15; padding-top:7;\" class=\"style5\">Pay amount:&nbsp;<b>".$_SESSION["mylimit"]." &euro;</b><br><br></div>";
    mysql_close($con);
    
    }}?>
    PHP:
    some words are in greek.
     
    Kyriakos, Sep 1, 2008 IP
  7. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #7
    $name = "";
    $email = "info@deftec.gr";
    $recipient = $_POST"mail"];
    while ($cart_r = mysql_fetch_assoc($cart_prods))
    {
    $mail_body .= "Model: ".$cart_r['model']."
    Quantity: 
    ".$cart_r['qty']."
    ---------------------------------------------------\n
    "
    }
    $mail_body .= "Pay amount: ".$_SESSION['mylimit']." €";
    $subject = "Defensive Technologies: automatic message"; //subject
    $header = "From: " . $email . "\r\n"; //optional headerfields
    
    mail($recipient, $subject, $mail_body, $header);
    PHP:
    Try that
     
    JAY6390, Sep 1, 2008 IP