Jump to content

Freedom-n-Democrazy

Members
  • Posts

    295
  • Joined

  • Last visited

    Never

Everything posted by Freedom-n-Democrazy

  1. haha yeah, thats what I meant, but its gonna be a little harder, but now the page that they see directly after adding just says "Product added to cart" (I'll change this later on to be more specific which item, size.. you know. I couldn't care for cosmetics now) Well, I re-engineered my flow and it worked, PERFECTLY, no hick ups what so ever (once it was implemented).... I cannot remember a time since the start of my 1.5 month PHP journey that this has happened. What I've done is, got my page to forward the data by FORM like this: <FORM action="../../../../cart/addtocart.html" method="post" name="form"> <DIV> Add <TEXTAREA class="quantity" cols="0" name="quantity" rows="0"></TEXTAREA> <SELECT class="size" name="size"><OPTION>Large</OPTION></SELECT> to <INPUT class="cart" type="submit" value="CART"> <INPUT class="id" name="id" type="hidden" value="<?php echo $id; ?>"> </DIV> </FORM> ... and then addtocart.html: <?php $quantity = $_POST['quantity']; $size = $_POST['size']; $id = $_POST['id']; $_SESSION['cart']['content'][] = array ('quantity' => $quantity, 'size' => $size, 'id' => $id); echo "Product added to cart."; ?> Now here comes a hick up. Quantity just stays as "1", so I tried this (note the +=>): $_SESSION['cart']['content'][] = array ('quantity' +=> $quantity, 'size' => $size, 'id' => $id); ... but nup! Any suggestions? I'm gonna read over what ManiacDan said earlier in the mean time.
  2. The $_SESSION wouldn't work for this case, however, I wasn't aware there was a hidden option with inputs. So awesome, thats gonna help allot! Thanks dude!
  3. Never mind, I just set it to margin-left: -44000px; problem solved! LOL... I'll fix this another day its not critical its just a cosmetical thing.
  4. Is it possible to set a TEXTAREA or INPUT element to 0 by 0 px? I am trying to carry over information in a form which is not suppose to be vissible to the viewer, and the bloody INPUT and TEXTAREA boxes only shrink to about 5 by 5px when I set them both to 0px. I tried to <DIV class="id" name="id" value="<?php echo $id; ?>"></DIV> but nope. I didn't think it would. Sure, I could probably absolute position them in CSS to margin-left:-500000px and set overflow to hidden, but thats just cheap. Any suggestions?
  5. I will be a little longer. I've found using HTML POST a MUCH better way to add to a cart. Its cleaner, more relaxing on my mind to code, and it doesn't have the problem where if someone hits refresh, it will add another item to the cart, where as .html?add=bla" did. Well, this does actually, but its less likely to occur. It also shows me that SESSIONS are not as hard as I thought.
  6. LoL hold up, I got a vision of a flow in my head. I wanna see how good I am. If I totally fail, then yeah I'll defiantly wanna check out your flow. Maybe keep that code close by LOL! I'll be done in about 20 I'm just gonna write it up now. Man why is it always the last thing that brakes ya balls! :S
  7. I'll be honest, 60% of the reason I didn't wanna role with ManiacDans suggestion is because I know I can do it, and I also know doing it means not going out for the rest of the night as I am going to have to change the flow in how things get added to cart from .html?thisway=bla, to a form... and its such as awesome night. Ok, I will do it. I'm gonna start getting to work on it now. Bloody hell what I am doing with my life. :S
  8. Didn't work as expected, its assigning the random number to all the same objects with the sam.e... hmmm hang on a second, each time I add something with the same name, they are not registering as two objects. Why?
  9. Thanks ManiacDan, I know what your saying but I want to use objects and have my cart show two of the same item if someone buys two, rather 2 x Item. Why? Because it mimics a real shopping cart. lol
  10. I was thinking of trying this. What do you think? if (isset($_GET['action']) && isset($_GET['size']) && $_GET['action'] == 'add') { $id = intval($_GET['id']); $size = $_GET['size']; $cartkey = rand (1, 1000000000) $_SESSION['cart']['content'][] = array ('size' => $size, 'id' => $id, $cartkey => $cartkey);
  11. An object in a $_SESSION. Buddski, maybe an array key can be created artificially on the way into the session? using a randomized number and associating it with the object in the foreach loop? Pretty sloppy I know, but hey it might work and save a re-write?
  12. Actually, MAYBE not! I would think there has to be array keys already. Is this a way to find out an array key for a session object? I've got an awesome idea that might save me from depression. LOLLL
  13. Shit. Looks like I am going to have to re-write my code to assign array keys to each object that is added into the session, right?
  14. I have a $_SESSION that I add to with these peices of code: if (isset($_GET['action']) && isset($_GET['size']) && $_GET['action'] == 'add') { $id = intval($_GET['id']); $size = $_GET['size']; $_SESSION['cart']['content'][] = array ('size' => $size, 'id' => $id); } <A href="index.html?action=add&id=1&size=sizel">Add to cart</A> I was wondering if theres a way to reverse this action? or must the cart be reset?
  15. I've got a DIV inside another DIV and I am trying make it centred using margin-left: auto; and margin-right: auto;, but its not working. This is the hierarchy in which the DIV (DIV.cartcontent) lives in: BODY { background-attachment: fixed; background-image: url("/bodybackground.png"); background-position: center; background-repeat: no-repeat; color: rgb(255,215,0); font-family: verdana } DIV.main { background-color: black; height: 636px; left: 50%; margin-left: -635px; margin-top: -307px; position: absolute; top: 50%; width: 1270px } DIV.cartcontent { border-style: solid; border-width: 1px; height: 562px; margin-left: auto; margin-right: auto; margin-top: 57px; overflow: auto; overflow-x: hidden; padding: 5px; position: absolute } Does anyone know why its not working?
  16. Ah shit you just beat me to it I was four attempts away from trying that combination of '..'. I looked at it from another perspective. I said to myself stop focussing on the fact I reversed the strings, and yeah, things started making sense. lol Thanks but! Hey, I noticed you did this yeah..: <B>Size:</B> '.$content["size"].' <BR> <B>Price: $</B> '.$row['price'].' Size has the double while price has the single. I have both mine single. Is there any difference? EDIT: In fact, it works with no quotes.. but I am going to keep the single quotes in to keep consistency amongst my code.
  17. Like I said in my original post, everything working fine, except the size not longer echo's "Large" since swapping the quotes, it now echo's "{$content["id"]}". http://i55.tinypic.com/34f01f6.png
  18. This is it: echo ' <IMG alt="" src="../products/'.$row['fordir'].'/'.$row['categorydir'].'/'.$row['id'].'/thumbnail.png"> <B>Product ID:</B> {$content["id"]} <BR> <B>Size:</B> {$content["size"]} <BR> <B>Price: $</B> $row[price] AUD <BR> <BR> ';
  19. Yeah, I tried it as just $echo also. Heres the code: echo ' <IMG alt="" src="../products/'.$row['fordir'].'/'.$row['categorydir'].'/'.$row['id'].'/thumbnail.png"> <BR> <B>Size:</B> {$content["size"]} <BR> <BR> ';
  20. I suck so hard its unbelievable! I tried braking out with: .size. ".size." "'.size.'" "size" 'size' '.size.' "'size'" '"size'" Fail. I then tried $content['size'] = $size; echo $size; ... and tried every combination again as listed above. Total failure!
  21. Ok, the original post was written shit house. I will start again I had: echo "{$content['size']}"; ... and this echoed "Large", which is correct. I then switched the quotes around, so its now like this: echo '{$content["size"]}'; The problem now is that instead of echoing "Large", it echo's "{$content["id"]} ". Why?!
  22. Its possible mate, the problem is your schools login probably uses some Novell/Windows domain system for login, which you will find difficult to ingrate with. What you could do is use PHP to perform system calls, and you'd have to find out what those system calls are need authentication passwords which the skool admin might not give you.
×
×
  • 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.