Jump to content



  • Please log in to reply
No replies to this topic

#1 suki2shoes

  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 06 April 2006 - 11:25 AM


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]

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users