Jump to content

suki2shoes

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

suki2shoes's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey 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 ---------------------------------------------------------------------------------------------------------------------- [code] <?php     $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]     exit;     }     ?>     <?php     $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)) {          if(parent=='3')     $total=(($total/100)*99);}                [b]  Calculation[/b]     ?>[/code]
  2. Hi. my website uses a session_id and sends this to my mysql database along with the details of the products the customer buys. When i'm using a query to echo the products the customer has bought, they are being called using $last_id = mysql_insert_id(); and the session id. therefore i am wondering as all the products are called using the session_id, if there is a way i can distinguish between between products to do calculations on the individual price or just simply display the data in a table. [a href=\"http://pastebin.com/632612\" target=\"_blank\"]http://pastebin.com/632612[/a] - sql call [a href=\"http://pastebin.com/632619\" target=\"_blank\"]http://pastebin.com/632619[/a] - sql insert queries if you see in the file above, i want description and price to go of each product to go into seperate rows, but becauase the call is on session_id they go into the same row. i know there probably easier ways like storing my values in arrays or osmething, but i'm novice and this is how i've done it now . Thanks for help in advance.
  3. hi guys learning php and i'm very stuck. [a href=\"http://pastebin.com/630534\" target=\"_blank\"]http://pastebin.com/630534[/a] - getting header sent already error, ln137, i guess its affected by the session include at top. [a href=\"http://pastebin.com/630511\" target=\"_blank\"]http://pastebin.com/630511[/a]. but dunno what the problem is. also, when my session_id is written to my db, its just staying at 0. even though i know a random number is being generated(just prinnted it to test). i'm not sure but maybe this is to do with lines 11-20 in [a href=\"http://pastebin.com/630534\" target=\"_blank\"]http://pastebin.com/630534[/a] also. thank you in advance for help
×
×
  • Create New...

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.