Jump to content


This topic is now archived and is closed to further replies.



Recommended Posts


This is what i'm trying to do :

I have a table "yacht_basket", that contains a parent field and every product bought will get the parent value of "1" in the table.

I want to SUM the parent field for the last session_id, and then :

if parent = 3

then take 1% off the total price. ( i have a price variable already called total, stored in the session ) $_SESSION['total'] = $total;}

so i want to take this total and do take 1% off the value, obviously if parent doesnt = 3 then just use the original value.

I am very new to php, but this is what i have so far, i dont know if i'm on the right lines though.
any advice would be greats, thanks



    $last_id = mysql_insert_id();
    $result=mysql_query("SELECT * FROM yacht_basket where session_id = $session_id");
    if (mysql_errno()!=0)
    echo mysql_error();                    [b]This will select the last session id[/b]

    $res3 = mysql_query("SELECT SUM(parent) from `yacht_basket` WHERE`yacht_basket`.`session_id`     = '$session_id'");                                
    echo mysql_error();                                  [b]SUMS the parent column for products of the session_id[/b]
    while ($row = mysql_fetch_assoc($res3)) {
    $total=(($total/100)*99);}                [b]  Calculation[/b]


Share this post

Link to post
Share on other sites


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.