marina Posted September 9, 2008 Share Posted September 9, 2008 i need some help with shoping cart script for my class project. this is my code if there is anyone that can explain this code to me i would be gratefull <?php function insert_narudzba($detalji_nar) { extract($detalji_nar); $conn = db_connect(); $query = "select kupacid from kupci where ime='$ime' and adresa='$adresa' and grad='$grad' and zip='$zip' and drzava='$drzava'"; $rezultat = $conn->query($query); if($rezultat->num_rows > 0) { $kupac = $rezultat->fetch_object(); $kupacid = $kupac->kupacid; } else { $query = "insert into kupci values ('', '$ime', '$adresa', '$grad', '$zip', '$drzava')"; $rezultat = $conn->query($query); if(!$rezultat) return false; } $kupacid = $conn->insert_id; $datum = date('Y-m-d'); $query = "insert into narudzbe values ('', $kupacid, ".$_SESSION['total_price'].", '$datum', 'PARTIAL')"; $rezultat = $conn->query($query); if (!$rezultat) return false; //this is a part of code that i realy don't understand for what purpose it is $query = "select narudzbaid from narudzbe where kupacid = $kupacid and iznos > ".$_SESSION['total_price']."-.001 and iznos < ".$_SESSION['total_price']."+.001 and datum = '$datum' and status_nar = 'PARTIAL'"; $rezultat = $conn->query($query); if($rezultat->num_rows > 0) { $narudzba = $rezultat->fetch_object(); $narudzbaid = $narudzba->narudzbaid; } else return false; foreach($_SESSION['cart'] as $sifra => $kolicina) { $detalji = get_disc_detalji($sifra); $rezultat = $conn->query($query); $query = "insert into stavke_nar values ('$narudzbaid', '$sifra', ".$detalji['cijena'].", $kolicina)"; $rezultat = $conn->query($query); if(!$rezultat) return false; } return $narudzbaid; } ?> tnx Marina Quote Link to comment https://forums.phpfreaks.com/topic/123504-need-help-with-shoping-script-for-my-class-project/ Share on other sites More sharing options...
revraz Posted September 10, 2008 Share Posted September 10, 2008 Let me understand this, this is a class project, but you need it explained? Ask your teacher? Quote Link to comment https://forums.phpfreaks.com/topic/123504-need-help-with-shoping-script-for-my-class-project/#findComment-638524 Share on other sites More sharing options...
marina Posted September 10, 2008 Author Share Posted September 10, 2008 actually i can not ask my teacher because he is a d... and he said that he won't help me.... i am asking you to help me if you can because, i really don't understand that part of the code.. thanks marina Quote Link to comment https://forums.phpfreaks.com/topic/123504-need-help-with-shoping-script-for-my-class-project/#findComment-638605 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.