Jump to content

7blake

Members
  • Content Count

    32
  • Joined

  • Last visited

Everything posted by 7blake

  1. Hi Just an outside point of view so I'm not sure if this is at standards, but how are people being made aware of your website? It looks more like a tool, so how are people coming across it? The main thing is you want clients to come to your site, so why/how are they finding out about this site? This is more of a communication issue, connecting the sites capability to the right audience, knowing how to get the right people to the right place. Perhaps the site is fully functional with the use of a database and php coding, but you're missing massive elements when it comes to communicating to regular people, and without sounding rude, the design makes me feel a bit uneasy. Could be why it's not being utilized, because I don't see something like this being searched for right off the bat. Generalized comparisons are not easy to set up off the bat, it would be better to grow your site into a platform that does product/brand listings/comparisons. But starting off just like that, you basically need a user who is looking to do product search. You really need a reputation or some anchoring elements for this to work in my opinion. Though, if you leading people from an already existing platform, and then to this site, but no one is using it, then it would be purely a design issue. Because the site doesn't really make any sense to me the way it's designed. Essentially it's just a barebones tool and the driving element is a user who knows exactly what they want when utilizing it. I'd suggest re-assessing what you are aiming for with the website, and communicating with a designer and marketing group to chisel it out properly. But.... where are you getting the massive amount of data to back up the challenge you are setting for yourself by creating a tool(website) like this? Can you explain what this website offers to the user, and what your overall objective is? Because, it's so general, it seems like you are aiming to show product listings from.. what? All online sources? Which sources? I'd say it's definitely not realized properly unless it's attached to the primary ecommerce website, to which there is no presence on this site.
  2. Yes thankyou both @Brand - IThanks for clarifying and supplying the correct way. I appreciate it. I was using the foreach on the Value, not the Key from the outer object. Bah. Thanks! @nik_jain - Thankyou for that bit of information. That's a pretty crucial fork in the road. Cheers
  3. basic ajax/php relationship below. You could set it up, and then have it on a timed loop function, if you need it to run during a specific set of time. It just needs some tweaking depending on the sort of data you are sending, but the overall base structure is there. $.ajax({ method: "POST", // Or GET url: 'path', // URL to your server page data: {parameter1: value1}, // parameters -- can be multiple. pareameter1 is what you target with $_POST['parameter1'] in PHP - value1 is your data. success: function(data) { // PHP's echoed data // Do something with the echoed data } //php if(isset($_POST['param1])){ $retrievedData = $_POST['parameter1']; echo $retrievedData; } });
  4. I'm grabbing an object with objects that is converted to JSON, then decoded in PHP newObject = {"firstObject":{"Color" : "red"}, "secondObject":{"Color":"blue"}}; anyhow, I can get this to PHP fine, and access it with the foreach loops. But I can't access "firstObject" or "secondObject". $someArray = json_decode($_POST['containerPositions'], true); foreach($someArray as $value){ foreach ($value as $secondKey){ echo getClass($value) . " " . $secondKey;} } Could someone tell me what is the correct method for accessing them?
  5. I'm grabbing an object with objects that is converted to JSON, then decoded in PHP newObject = {"firstObject":{"Color" : "red"}, "secondObject":{"Color":"blue"}}; anyhow, I can get this to PHP fine, and access it with the foreach loops. But I can't access "firstObject" or "secondObject". $someArray = json_decode($_POST['containerPositions'], true); foreach($someArray as $value){ foreach ($value as $secondKey){ echo getClass($value) . " " . $secondKey;} } Could someone tell me what is the correct method for accessing them?
  6. Ah, my apologies. if I could correct my statement I would. (too late to edit) Thanks iThinkMyBrainHurts
  7. Thanks alot, got the ball rolling So incase anyones new and interested too, to capture the dynamic state of the HTML you only need var x = $("body").html(); alert(x); To capture the saved state of a file and send via aJax $.ajax({ url: "fileName.php", type: "POST", dataType: "text", success: function(data) { alert(data); } }); I'm not sure how to capture dynamic variables in Javascript though. I suppose it just needs a script to update an array, then send the array that way. Thanks for the info maxxd
  8. Hi. Not too sure how to word this right. I remember once when I was learning how to send javascript variables to PHP, I accidentally sent a capture of the entire index.php. Ive been trying to find the answer online but I guess im not wording it right. Does anyone know how to do this?
  9. Yar i found it. I was using javascripts .replace to clear the 'url(http://localhost/' portion earlier. But I had two quotes, so it was effectively doing what I wrote it to do.. nothing. Thanks for the perk up. This had nothing to do with PHP, Ill ask a mod to delete or move this thread. And Ill read your suggestion eventually. My heads a bit preoccupied at the moment. It looks simple, but vital if I intend to actually build sturdy secure infrastructure. It's appriciated. Take care
  10. For real? I had to put $item_id = str_replace("url(http://localhost/Online/inventory_images/", "", $item_id); $item_id = str_replace(".jpg)", "", $item_id); Into each one of my functions that called the ID from each item of the cart. Well, guess that solves that problem for now.
  11. Probably a stupid question. Just a bit unsure.. I wish they'd regulate primary "language" throughout their browsers. Though I guess no one wants to conform to the other, which is fair... So what do I do? I can fix the URL issue with $item_id = str_replace("url(http://localhost/Online/inventory_images/", "", $item_id); $item_id = str_replace(".jpg)", "", $item_id); But this seems stupid. Why is it doing that? Is this normal? And what is wrong with my $product_name... it's not registering
  12. Hi, I'm not sure where the problem is here. Right now this site works fine in IE and FF, but then I try to load data from the database into the cart, it get's screwed up in Chroms and Safari. FF loads <img src="inventory_images/11.jpg" alt="Some item" id="11" class="cartImages" border="1"> While Chrome loads this <img src="inventory_images/url(http://localhost/Online/inventory_images/11.jpg).jpg" alt="" id="url(http://localhost/Online/inventory_images/11.jpg)" class="cartImages" border="1"> From this if(isset($_POST['miniCartRequest'])){ include "/storescript/connect_to_mysql.php"; $cartOutput = ""; $cartTotal = ""; $product_name=""; $price=""; if(!isset($_SESSION['cart']) || count($_SESSION['cart'])<1){ $cartOutput = "<h2 align='center' style='color:white;'>Your cart is empty</h2>"; } else { $i = 0; foreach($_SESSION['cart'] as $each_item){ $item_id = $each_item['item_id']; $sql = $mysqli->query("SELECT * FROM products WHERE id='$item_id' LIMIT 1"); while($row = $sql->fetch_array()){ $product_name = $row['product_name']; $price = $row['price']; $details = $row['details']; $size = $row['size']; } $pricetotal = $price*$each_item['quantity']; $cartTotal = $pricetotal + $cartTotal; setLocale(LC_ALL, 'en_GB.utf8', 'en_GB'); $pricetotal = number_format($pricetotal, 2); $x = $i + 1; $cartOutput .= "<img src='inventory_images/" . $item_id . ".jpg' alt='" . $product_name . "' id='" . $item_id . "' class='cartImages' border='1' />"; $i++; } } echo $cartOutput; } Can I create an alternative line of code specificall for Chrome/safari to remove the excess characters? And why exactly are they reading the files with the full source locations vs firefox reading only the local location? It's completely unable to read the $product_name aswell. A bit strange, I take it those browsers process the specific information differently?
  13. Oh man.. thankyou very much for explaining that. I was just on the tail of figuring that out. Very much appriciated for the information and time. if(isset($_POST['mainCartDelete'])){ $cartArray = $_SESSION['cart_array']; $test = ""; foreach($cartArray as $key => $item) { $test .= $key . " "; if($key == 21){ unset($_SESSION['cart_array'][$key]); } } echo $test; }
  14. HI, I'm having trouble with unsetting a key from SESSION. I can unset the cart, but when I try to target the key, it doesn't work. Are there some regular things I should be looking for? The only thing I can think of is that I'm re-initializing the key by accident elsewhere in my code. if(isset($_POST['mainCartDelete'])){ unset($_SESSION['cart_array'][21]); $sessionArray = $_SESSION['cart_array']; print_r ($sessionArray); } Print_r returns Array ( [0] => Array ( [item_id] => 21 [quantity] => 1 ) )
  15. Ah great. Do you know what's wrong with my application of slice? $pageLocation = $_GET['inputimages']; // assume "page1" // assume "page2" $selectedArray = str_replace("page", "", $pageLocation); // leaves 1 // leaves 2 $endPoint = intval($selectedArray) * 5; // 1*5 == 5 // == 10 $startPoint = $endPoint - 5; // 0 // 5 ect echo json_encode(array_slice($all_images, $startPoint, $endPoint));
  16. tryingtolearn Oh. Looking at your code, maybe I can do this the way you used arrayChunk. foreach($pages[$currentPage] as $file){ echo $file.'<br />'; } Ill give this a try. Sorry I didn't try using your code first, but Ill give this a go in the meantime I appriciate the share
  17. Thankyou very much for the replies. I've been trying a few methods tbh. I tried array_chunk first, but I don't know how to access in the interior arrays individually. It'd be alot easier. My thought process is this. //scan directory for images & count // divide totalCount to provide pageCount // Create an array of total pages and send through Ajax //inAjax Create Container Pages and Page buttons //when a page button is clicked, send corresponding page number back through ajax and grab the array_chunk array associated with that number, and display it *alternative // use the array_slice and use a combination of ranges related to the recieved page number to send the section of the Glob() array. The problem is with Slice is, it just mucks up the way I am using it. I'm having trouble with glob()'s sorting. I have images named "image1, image2, image3 -------- image 11, image 12, ect" It thinks the correct order is "image 1, image 10, image11 ++" Sort of a bind. I tried sort() but I didn't utilize it right with glob() apparently, so I'll have to play about with it more. Problems with Slice (from a total of 15 images) On page 1 I recieve 5 images. On page 2 I recieve 10 images (the addition 5 should be for page 3) On page 3 I recieve the final 5(which also appear on page 2) So that's awkward. Plus the odd sortment this is the major issue. I think array_chunk would be alot cleaner, I'm not too sure it matter which. But I'd like to understand how to use both, I'll concentrate on slice() atm. I was wondering if anyone could give me a heads up on what I'm doing wrong,. This method might go completely against the standard for doing this. I'll eventually conform this structure to todays standard. Right now I'm more trying to just get this working the way it is. Though I'll be honest, Ill definitly have to re-configure it so I only need to make 1 ajax call. Right now it's too many. But that's something I can fix later once I understand how to do this portion right I think. $(document).ready(function() { $.get( 'images.php', {"pageNumbers" : 0}, function(data) { $.each(data, function(k,v){ $("#cartStatus").append("<div id='page" + v +"' class='pages'>"+ v + "</div>"); }) }, "json" ) $.get( 'images.php', {"pageNumbers" : 0}, function(data) { $.each(data, function(k,v){ $("#cartStatus").append("<div id='page" + v +"Number' class='pageNumber'>"+ v + "</div>"); }) }, "json" ) $('#cartStatus').on('click', 'div', function() { var nameId = $(this).attr("id"); nameId = nameId.replace("Number", ""); $(".pages").fadeOut(); $("#" + nameId).empty().delay(400).fadeIn(); $.get( 'images.php', {"inputimages" : nameId}, function(data) { $("#" + nameId).append(data); }, "json" ) }); }); <?php session_start(); $pageArray = array(); $all_images = glob("*.jpg"); $arrayCount = count($all_images); $pageCount = ceil($arrayCount/5); $startPageCount = 1; for ($x = 1; $x <= $pageCount; $x++){ $pageArray[] = $x; if($x == $pageCount){ if(isset($_GET['pageNumbers'])) { echo json_encode($pageArray); } } } if(isset($_GET['inputimages'])){ $pageLocation = $_GET['inputimages']; $selectedArray = str_replace("page", "", $pageLocation); $endPoint = intval($selectedArray) * 5; $startPoint = $endPoint - 5; echo json_encode(array_slice($all_images, $startPoint, $endPoint)); } ?>
  18. Hi, I'm trying to make a gallery, and it more or less works. But I don't like having to load so many images for the user to view. What happens is I have a very basic method of loading the images into the index file using require. <?php foreach (glob("*.jpg") as $filename) { echo "<div class='itemContainer'><img src='" . $filename . "' class='item' id='" . $filename . "' /></div>"; } ?> Pretty simple. but it just loads everything in the directory. What I'd like to do is make it so 30 images load, and then it creates a new "div container" and loads the next 30 in. As well as a page counter, and a next and previous button. I'm not too sure how to control the flow of information from PHP to the index file when using require. Or if this is even the right way of doing it. My thoughts are sorta like this $imageCounter = 0; $newPageStandard = 30; foreach($imageDir as $image){ // echo image; $imageCounter++ if($imageCounter == $newPageStandard){ $newPageStandard += $newPageStandard; // increase standard for next page if there are enough images //create new image container(div) //somehow re-direct the echo into this new image container } // continue echoing images } Something Along those lines. Is this at all on the right path, or should I be grabbing all the images, and stuffing them into an multidimensional array and breaking each array into segments of 30? Or perhaps another completely different method? (yeah I dont have a clue what Im doing atm)
  19. Ah you got me thinking I've been trying to do this with json_encode.. when infact I can just do it with basic ajax/php data transfer. (Sorry, I don't know the correct way of saying this). Here's my code. <!DOCTYPE HTML > <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type='text/javascript'> $(document).ready(function() { $("#updateCart").click(function() { // Update view on cart $("#cartStatus").fadeOut(function() { $(this).empty(); $.get( 'info.php', {"cartDisplay2" : "test"}, function(data) { $('#cartStatus').append(data); }); }).fadeIn(); }); var name; $(".item").click(function() { // select Item name = $(this).attr("id"); $(".item").css({"border" : "1px solid black", "color" : "black"}); if (this.id== name){ $(this).animate({width:"0px", height:"0px", top:"+=25px", left:"+=25px"}, 200, function() { $(this).css({"border" : "1px solid blue", "color" : "blue"}); }).animate({width:"50px", height:"50px", top:"-=25px", left:"-=25px"}, 200); } }); $("#button").click(function() { // Add to Cart $("#click").fadeOut(300, function() { $(this).empty(); $.get( "info.php", {"name":name}, function(data) { $.each(data, function(k,v){ $("#click").append(k + " : " + v + "<br />").fadeIn(); }) $("#click").append("--------------------\n"); }, "json" ) }); }); $("#minus").click(function() { // Minus From cart $("#click").fadeOut(300, function() { $(this).empty(); $.get( "info.php", {"name1":name}, function(data) { $.each(data, function(k,v){ $("#click").append(k + " : " + v + "<br />").fadeIn(); }) $("#click").append("--------------------\n"); }, "json" ) }); }); $("#clear").click(function() { // Clear from Cart $("#click").fadeOut(300, function() { $(this).empty(); $.get( "info.php", {"clear":name}, function(data) { $.each(data, function(k,v){ $("#click").append(k + " : " + v + "<br />").fadeIn(); }) $("#click").append("--------------------\n"); }, "json" ) }); }); }) </script> <style> #container { position:absolute; width:10%; height:15%; top:5%; border:1px solid black; overflow:auto; } #cartStatus { position:absolute; width:12%; height:20%; top:5%; left:11%; border:1px solid black; } .item { width:50px; height:50px; position:absolute; border:1px solid black; font-size:.75em; text-align:center; top:266px; } #item1 { left:10px; } #item2 { left:64px } #item3 { left:118px } </style> </head> <body> <input type="button" name="button" id="button" value="Add"> <input type="button" name="minus" id="minus" value="Minus"> <input type="button" name="clear" id="clear" value="Clear"> <input type="button" name="clear" id="updateCart" value="updateCart"> <div id="container"> <div id="click"></div> </div> <div id="cartStatus"> </div> <div id="item1" class="item">Item 1</div> <div id="item2" class="item">Item 2</div> <div id="item3" class="item">Item 3</div> </body> </html> <?php session_start(); // Add to Cart if (isset($_GET['name'])) { $itemId = $_GET['name']; if (isset($_SESSION['cart'][$itemId])) { $totalPrice = 2.5; $_SESSION['cart'][$itemId]['Quantity']++; $quantity = $_SESSION['cart'][$itemId]['Quantity']; $price = $_SESSION['cart'][$itemId]['Price']; $totalPrice = $quantity * $price; $_SESSION['cart'][$itemId]['TotalPrice'] = $totalPrice; } else { $totalPrice = 2.5; $_SESSION['cart'][$itemId] = array('Id' => $itemId, 'Quantity'=>1, 'Price'=>2.50, 'TotalPrice' => $totalPrice); $quantity = $_SESSION['cart'][$itemId]['Quantity']; $price = $_SESSION['cart'][$itemId]['Price']; $totalPrice = $quantity * $price; $_SESSION['cart'][$itemId]['TotalPrice'] = $totalPrice; } echo json_encode($_SESSION['cart'][$itemId]); } else echo ''; // Minus from Cart if (isset($_GET['name1'])) { $itemId1 = $_GET['name1']; if (isset($_SESSION['cart'][$itemId1])) { $_SESSION['cart'][$itemId1]['Quantity']--; $quantity = $_SESSION['cart'][$itemId1]['Quantity']; $price = $_SESSION['cart'][$itemId1]['Price']; $totalPrice = $quantity * $price; $_SESSION['cart'][$itemId1]['TotalPrice'] = $totalPrice; } else { $totalPrice = 2.5; $_SESSION['cart'][$itemId1] = array('Id' => $itemId1, 'Quantity'=>1, 'Price'=>2.50, 'Total Price' => $totalPrice); $quantity = $_SESSION['cart'][$itemId1]['Quantity']; $price = $_SESSION['cart'][$itemId1]['Price']; $totalPrice = $quantity * $price; } echo json_encode($_SESSION['cart'][$itemId1]); } else echo ''; // Clear from Cart if (isset($_GET['clear'])) { $itemClear = $_GET['clear']; if (isset($_SESSION['cart'][$itemClear])) { $_SESSION['cart'][$itemClear]['Quantity'] = 0; $quantity = $_SESSION['cart'][$itemClear]['Quantity']; $price = $_SESSION['cart'][$itemClear]['Price']; $totalPrice = $quantity * $price; $_SESSION['cart'][$itemClear]['TotalPrice'] = $totalPrice; } else { echo ''; } echo json_encode($_SESSION['cart'][$itemClear]); } else echo ''; // Display Cart Contents if(isset($_GET['cartDisplay'])) { echo json_encode($_SESSION['cart']); } if(isset($_GET['cartDisplay2'])) { foreach ($_SESSION['cart'] as $item => $value){ foreach($_SESSION['cart'][$item] as $test){ echo $test . " : "; } } } ?> (it's just a practice one. There's lots of things not coded in. Nothing is unset, or disabling -1 counters, or the cart display when there are no contents. But it works fine for now I think. Unless you can see I'm going about something very wrong to the standards today) So this sorta works fine. I can just design the PHP itself to be better displayed. So is one of json's methods for passing entire arrays through ajax?
  20. I recently posted a simple query about ISSET and finally got that simple problem solved thanks to you guys. But I've hit a new snag. I've create a simple sort of cart, or record counter. While I can add/remove/clear items and display their affilated arrays, I don't know how to cycle through a multidimensional array that is dynamically set. Something like $_SESSION['Primary'][$items][$attributes] - Where $items is a dynamic set, and $attributes is a fixed set of keys with values. I can target individual $Items, or display all the items in there. But I can't display all the Items and their subsequent $attributes aswell. Do I have to write 1 set of Ajax code for just displaying the $items, and another for each individual set of $attributes? Or is their a way to cycle through each $item, and then all of it's(or specific) $attributes and values? I've tried using loops which logically work, but I can't pass it through json_encode. Is there any documentation I could read in relation to this? I feel this is the key component to manuvering through a database of sorts. I'm just not entirely sure how to go about accessing multidimensional Array's without a ton of code that becomes redudent. And even then, it wouldnt work well with a dynamic setup.
  21. Well, as it's going so far it's helped a great deal. I really appriciate the time Hopefully I'll start to understand the broader complexity of what I'm doing. But atleast I understand how to get this part working lol Thanks again. I'll probably be posting another deliema soon :S
  22. Gotcha. PHP returns the data as an array via jSon, and using $.each(Data//(returned array, breaks it down into it's key/value via function variables)// function(x, y)); ^^ poor writing but I think I get you. Is that the primary function of $.each? Or merely just an application of it? Does this mean, for each click, the each function will iterate over every key and value in the given array target? (sorry for the questions, it's quite rare to actually talk to someone who knows what they are doing )
  23. Wow thanks. Yes, that is generally what I was attempting to do. You made more of a modification to the aJax than the PHP. I can mostly understand it, but not entirely. In this case we're using a GET instead of POST, so I'll have to figure this out. But once the data is retrived, you started $.each(data, function(x, y) // In relation to $array('var1'=>1, 'var2'=>2); I'm not sure what the each means. The data is grabbed, so does the each isolate the key and value from the array, via x/y? Like "for each Value/Key in the array(represented by X/y) perform action?". Thanks a bunch for helping to get it to work. Now I just have to understand it
  24. Narh, I neglected to post the entirety of the index file. But it's at the beginning of the file. Conceptually what I've written makes sense though right?
×
×
  • 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.