Jump to content
Stef's Coding Community

Korken

Member
  • Content Count

    10
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Korken

  • Rank
    New member

Profile Information

  • Location
    Lule?, Sweden

Contact Methods

  • Other
    emil.fresk@telia.com
  1. I would recommend Eclipse. There are versions for both Linux and Windows. //Emil
  2. Hmm, something like this should probably work: >function render_products_from_xml() { $output = "</pre> <table> $product->title $product->description ?$product->price add to cart </table>";<br><br> return $output
  3. Add a counter, and when you reach 3 print " Hope it helps! //Emil Edit: Example, somthing like this: $i = 0; echo ""; foreach (get_shopping_cart() as $prod) { echo "$prod"; if ($i >= 2) { echo ""; $i = 0; } else i++; } echo "";
  4. Is this what you wanted? Then will each one beome it's own row in the database. Hope it helps. foreach($_POST['Activity'] as $row=>$Act) { $Activity = mysql_real_escape_string($Act); $Position = mysql_real_escape_string($_POST['Position'][$row]); $StartDate = mysql_real_escape_string($_POST['StartDate'][$row]); $EndDate = mysql_real_escape_string($_POST['EndDate'][$row]); $involv = "INSERT INTO Involvement(Activity, Position, StartDate, EndDate) VALUES('$Activity', '$Position', '$StartDate', '$EndDate')"; mysql_query($involv); }
  5. This may help I just watched the free movies and then worked on the rest by my self. <?php /********************************************************************** * - Made in the Eclipse IDE: www.eclipse.org * - Tested on PHP 5.2 * - Kickstart in OOPHP: www.killerphp.com * * Usage of the class ShoppingCart * * Attention!: product_id is a string and value is an integer. * * -> addItem("product_id"): * This will add an item to the cart. * If the item already exists, the quantity of that item will increased by 1. * * -> deleteItem("product_id"): * This will remove an item from the cart. * Remove as in it will be gone, if you want to change the quantity see 'SetQuantity'. * * -> getItems(): * This will return an array with all the items in the cart. * * -> setQuantity("product_id", value): * This will change the quantity of the item to value. * If value is 0 the item will be automatically removed. * * -> getQuantity("product_id"): * This will return the quantity of the item. * * * Design of the cart array: * _______________________ * | Product ID | Quantity | * | (string) | (int) | * |------------|----------| * | exampleid1 | 5 | * |- - - - - - | - - - - -| * | exampleid2 | 3 | * |- - - - - - | - - - - -| * | exampleid5 | 13 | * ----------------------- **********************************************************************/ class ShoppingCart { private $cart = array(); public function addItem($product_id) { if (array_key_exists($product_id, $this->cart)) $this->cart[$product_id] += 1; else $this->cart[$product_id] = 1; } public function deleteItem($product_id) { if (array_key_exists($product_id, $this->cart)) unset($this->cart[$product_id]); } public function getItems() { return array_keys($this->cart); } public function setQuantity($product_id, $value) { if (array_key_exists($product_id, $this->cart)) { if ((int)$value > 0) $this->cart[$product_id] = (int)$value; else unset($this->cart[$product_id]); } } public function getQuantity($product_id) { if (array_key_exists($product_id, $this->cart)) return $this->cart[$product_id]; } } ?>
  6. Hmm, it sems the array is a bit wrong; $prices_array = array("TV" => "250.00", "DVD" => "100.00", "VHS" => "2.00", ); Should be (notice the last ", " i removed): $prices_array = array("TV" => "250.00", "DVD" => "100.00", "VHS" => "2.00"); //Emil Fresk Sweden
  7. Yes, I noticed quite a big change! Sometimes I had to wait for a minute or so before anything happened but now it's just *poff* and it's ready. //Emil Fresk Sweden
  8. Korken

    a littel help...

    I'm not that much a fan of "Give me the code!" sulutions, so I will give you the means to complete it yourself. Forms: http://www.tizag.com/htmlT/forms.php PHP GET & POST: http://www.tizag.com/phpT/postget.php Video: http://www.killerphp.com/videos/07_html_forms_part_01/07_html_forms_part_01.html Give it a try and you will solve it. If not, ask for help again. //Emil Sweden
  9. Perhaps something like this: function set_onSubmit(ACT, ID) { var myForm = document.getElementById(ID); myForm.setAttribute("onSubmit", ACT); } And you could have a button or something: Hope it helps! //Emil Fresk Sweden
  10. Edit: Changed the code a bit. Hello! This is my 2nd post here (Sorry for the wrong forum with the first one! :| ) and my first try at OOPHP. I watched the beginner videos, looked at the first three (free) movies of the shopping cart tutorial and decided to finnish it without any more help to see how it became. So after a few hours I ended up with this: Please comment if I should have done anything in a different way or if it looks okey. Thanks for the tutorials KillerPHP! //Emil Fresk Sweden Code: <?php /********************************************************************** * - Made in the Eclipse IDE: www.eclipse.org * - Tested on PHP 5.2. * - Kickstart in OOPHP: www.killerphp.com * * Usage of the class ShoppingCart * * Attention!: product_id is a string and value is an integer. * * -> AddItem("product_id"): * This will add an item to the cart. * If the item already exists, the quantity of that item will increased by 1. * * -> DeleteItem("product_id"): * This will remove an item from the cart. * Remove as in it will be gone, if you want to change the quantity see 'SetQuantity'. * * -> GetItems(): * This will return an array with all the items in the cart. * * -> SetQuantity("product_id", value): * This will change the quantity of the item to value. * If value is 0 the item will be automatically removed. * * -> GetQuantity("product_id"): * This will return the quantity of the item. * * * Design of the cart array: * _______________________ * | Product ID | Quantity | * | (string) | (int) | * |------------|----------| * | exampleid1 | 5 | * |- - - - - - | - - - - -| * | exampleid2 | 3 | * |- - - - - - | - - - - -| * | exampleid5 | 13 | * ----------------------- **********************************************************************/ class ShoppingCart { private $cart = array(); public function AddItem($product_id) { if (array_key_exists($product_id, $this->cart)) $this->cart[$product_id] += 1; else $this->cart[$product_id] = 1; } public function DeleteItem($product_id) { if (array_key_exists($product_id, $this->cart)) unset($this->cart[$product_id]); } public function GetItems() { return array_keys($this->cart); } public function SetQuantity($product_id, $value) { if (array_key_exists($product_id, $this->cart)) { if ((int)$value > 0) $this->cart[$product_id] = (int)$value; else unset($this->cart[$product_id]); } } public function GetQuantity($product_id) { if (array_key_exists($product_id, $this->cart)) return $this->cart[$product_id]; } }
×
×
  • Create New...