Jump to content

xlxprophetxlx

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

About xlxprophetxlx

  • Birthday 06/12/1985

Profile Information

  • Gender
    Male
  • Location
    Pennsylvania

xlxprophetxlx's Achievements

Member

Member (2/5)

0

Reputation

  1. userid is defined further up in my coding but in this example it shouldn't matter since $userfinal == "" is true as shown. and it's not outputting echo $useridstring; for some reason.
  2. I can't seem to echo this out of a function: mt_srand ((double) microtime() * 1000000); $useridstring = md5(uniqid(mt_rand())); $userfinal = ""; function useridfun(){ if($userfinal == ""){ echo $useridstring; }elseif($userfinal == $userid){ echo $userfinal; } } useridfun() This is pretty much driving me nuts. I had it working earlier but now it doesn't seem to want to work. If I print or echo $useridstring by itself it works but not within the function. It got to be something I'm just over seeing. Thanks!
  3. Correct. There really is no need for the data to be saved after the browser is closed. I'm just looking for an instance. Adding a lifespan of a day on the cookie would be the longest time period I foresee needed if any. With the multi-dimensional array I was thinking each array would increment by one (i++) with a loop: 0 => Array1, 1 => Array2, 2=>Array3 ect.. Just unsure the exact order to write the loop to allow items to be added.
  4. Instead of involving a database would it be possible to use a multi-dimensional array or just have a cookie that stores the information? This doesn't need to be secure, it just for random users to create a quick grocery list. Like array(array1, array2, array3, array4, ect...) and each array contains the id, category, product_name, note, qty of each custom product added. Possibly have a mini cart that loops through the arrays and shows the product name, qty and a delete next to it. The delete would use unset what ever the that array would be. Under the mini cart would have a view whole cart which would be exactly like the mini cart but with the addition of showing the note. Thanks for the help.
  5. I think your over complicating the code. I would do this for example (use for a basic structure; modify as needed): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <style type="text/css"> html, body{ margin:0; padding:0; } #container{ margin:0 auto; /* Too Center the Div */ width:960px; /* For Example */ } #container div{ float:left; display:inline; width:300px; /* Even Columns while compensating for padding */ padding:10px; } </style> <div id="container"> <div> <!--New Query--> <h1>Category Title</h1> <ul> <li>list item</li> <li>list item</li> <li>list item</li> <li>list item</li> </ul> <!--New Query--> <h1>Category Title</h1> <ul> <li>list item</li> <li>list item</li> <li>list item</li> <li>list item</li> </ul> </div> <div> <!--New Query--> <h1>Category Title</h1> <ul> <li>list item</li> <li>list item</li> <li>list item</li> <li>list item</li> </ul> </div> <div> <!--New Query--> <h1>Category Title</h1> <ul> <li>list item</li> <li>list item</li> <li>list item</li> <li>list item</li> </ul> <!--New Query--> <h1>Category Title</h1> <ul> <li>list item</li> <li>list item</li> <li>list item</li> <li>list item</li> </ul> </div> </div> </body> </html> The problem you are running into is box level elements. You technically only need 3 columns and 1 row if you were going to do a table layout. I would use the above as a reference and swap out as needed.
  6. Hello everyone. Looking for a little help here. I am trying to make a simple grocery list. I got it to print out the full array but I need another item to be added each time I add a new one then the ability to delete/modify the item. Can anyone lead me in the right direction? <?php session_start(); $id = $_POST['id']; $category = $_POST['category']; $product_name = $_POST['product_name']; $note = $_POST['note']; $qty = $_POST['qty']; $_SESSION['id'] = $id; $_SESSION['category'] = $category; $_SESSION['product_name'] = $product_name; $_SESSION['note'] = $note; $_SESSION['qty'] = $qty; function addCustomProductToSession() { if(isset($_POST['id'])){ $custom_items = array($_SESSION['id'], $_SESSION['category'], $_SESSION['product_name'], $_SESSION['note'], $_SESSION['qty']); foreach ($custom_items as $key => $custom_item) { $custom_items[$key] = $custom_item; } print_r($custom_items); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Grocery List</title> <script type="text/javascript"> <!-- function formsubmit(form) { form.action = 'index.php'; return true; } //--> </script> </head> <body> <p>Add Your Custom Product</p> <form action="" method="post" id="cart" onsubmit="formsubmit(this);"> <div><input name="usedb" id="usedb" value="0" type="hidden" /></div> <div><input name="id" id="id" value="<?php echo rand(400, 5000); ?>" type="hidden" /></div> <div><input name="category" id="category" value="18" type="hidden" /></div> <p><input size="15" id="product_name" name="product_name" onfocus="this.value=''" value="Enter Product Name" type="text" /></p> <p><input size="15" id="note" name="note" onfocus="this.value=''" value="Enter Note Here" type="text" /></p> <p><input name="qty" id="qty" maxlength="2" size="1" value="1" type="text" /></p> <p><input type="submit" name="submit" value="submit" /></p> </form> <?php echo "<br /><br /><br />"; addCustomProductToSession(); ?> <p><a href="#" onclick="destroy()">Destroy Session</a></p> </body> </html> Thanks for the help in advance! -Mike
  7. Hello, I am having a little trouble getting some of my code to work. I converted this: http://v3.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart ... Working demo doesn't work. To act more like a Shopping List instead of a Shopping Cart. The client would like to the ability for a user to add a custom item then when viewing the shopping list the ability to add a note (simple input field). When the user is done they will be able to print the list out. An example of what I have done is here: http://www.econnectatgmdd.com/shopping_cart/index.php I am currently working on this section: http://www.econnectatgmdd.com/main_shopping_cart/index.php it is somewhat working but I am using $_POST instead of a SESSION which is what I should really be using. Is there any suggestions on what I might be doing wrong? Attached is what I have thus far. It's not pretty at the moment because I am still working on it. Any incite would be appreciated. Thanks, -Mike [attachment deleted by admin]
×
×
  • 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.