Jump to content

1internet

Members
  • Posts

    136
  • Joined

  • Last visited

Everything posted by 1internet

  1. The HTML part is what I wasnt sure of Would it be something like this? <input type="checkbox" name="makes[]" value="1"> <input type="checkbox" name="makes[]" value="4"> <input type="checkbox" name="makes[]" value="7"> So it creates an array of makes[], and serializes all the ones that are checked, and passes them through as an array? Can $_POST accept the array? Then I guess I would implode the array?
  2. I have a list of checkboxes, for a filter for manufacturers. I want the checkboxes to update the search results on click, when a new manufacturer is selected or de-selected. The ajax code picks up the checked items from the form like this $('.new_make_button').click(function(){ // when a feature button is selected var serialize = $('#new_make_form').serialize(); // takes all the values of the filter $.ajax({ type : 'POST', url : '../ajax/new_makes.php', // sends the values to ajax file data : serialize, success : function(data) { $("#new_results").html(data); } }); }); I want to add all the selected manufacturer_ids into a list like (1,4,7,10), and set them in a session and run the class, with the updated session. <?php if(isset($_POST['makes'])) $_SESSION['new_results']['makes'] = $_POST['makes']; include '../classes/new-results.php'; $result = new NewResults; $_SESSION['user']['new']; return $result->results(); ?> How can I pass the manufacturer IDs of only the selected manufacturers to the ajax file through the form #new_make_form. How should the html form work to accomplish this? Or do I need to make adjustments in the ajax files? I also am not sure about what the variable for $_POST should be, I have used 'makes' as an example, but not sure how it can catch them all at once.
  3. I have considered CSS, and I don't mind using it, but couldn't see anything. @fastol, I think that might work, need to play with it a bit
  4. I want to have completely custom checkboxes and radio buttons. This would entail: 1. a text label 2. a background icon 3. a hover effect 4. an active effect 5. and a click effect I don't want any checkbox or radio icons, I just want them to look like buttons. I have been experimenting with jquery but dont seem to be able to get much further than the default styling. Any suggestions are much appreciated.
  5. What if we used a combination of both, e.g. it downloads the first 5 pages, and if a visitor tries to go further than those results it dowloads the next 5 pages of results too?
  6. I want to have my results slide out and slide in just like a carousel. So my results are 3x3, and then whenever you click next, the existing results slide out to the left, and at the same time the new results slide in from the right hand side. If this is done then would it mean I have to download all the results, so they are stored, and can thus slide in immediately, without an ajax load? Or is there some other amazing way to accomplish a task like this?
  7. Ah, thats what I thought! Thanks
  8. I want to list results that belong to a certain category. However, I have multiple categories and some results can belong to more than one cateogry. I want to a query that will show all the results from several categories, the number of categories will be aribitrary though. So I will have the categories contained within an array e.g. $cat_ids = array(12,26,32) And I want the query to be $sql = "SELECT * FROM `categories` WHERE `cat_id`=12 OR `cat_id`=26 OR `cat_id`=32"; Of course sometimes there may only be 1 category, and sometimes there could be 5. So how do you execute the array in the query? Or do I have to run a foreach loop? $sql = "SELECT * FROM `categories` WHERE" $i = 0; foreach ($cat_ids AS $cat_id){ if($i!=0) $sql = "OR " $sql = "`cat_id`=$cat_id" $i++ }
  9. Sorry, I mean the top tag when you post a topic
  10. So with the Topic Tags field just above, when i add a comma it creates a tag. How is that done? And how does it feed into the database?
  11. e.g. $q = mysql_query(SELECT * FROM `table`); <div> while($r = mysql_fetch_assoc($q)) { echo $r['name']; } </div> But how do I split that into 4 divs: <div id="1"></div><div id="2"></div><div id="3"></div><div id="4"></div>, withouth having to do 4 sepate queries?
  12. Nothing, its just returning a list of rows, but in 4 columns rather than one long list.
  13. If I wanted to display database results in 4 different columns, would that essentially mean I have to run 4 different sql queiries with each of them limited, or is there another way around that?
  14. Ok, sorry, that was just how I inferred it. On a lighter note, it works now. So thanks.
  15. I don't appreciate the sarcasm, it was a genuine question, if you don't want to help then thats fine.
  16. Can you elaborate?
  17. I am going crazy with my ajax calls. I have finally discovered the issue, but tried numerous ways to fix it with no avail. So essentially I have an ajax call from different levels in the site, there could be from 1 to 4 different directories in the url of the site, which is what causes the issues. function add_cart(pid,quantity) { $.ajax({ type : 'POST', url : '../../ajax/add-cart.php', data : 'pid='+pid+'&quantity='+quantity, success : function() {} }); } I have tried changing the path to http://www.mydomain.com/ajax/add-cart.php, /ajax/add-cart.php, document.location.origin+"/ajax/add-cart.php", "//www.mydomain.com/ajax/add-cart.php" But nothing is working. I am sure I am not the first person to run into this issue, so what is the answer?
  18. I have been learning php for just over a year now, and am getting pretty good at procedural coding. But now I can feel it is time to take it to the next step and be all about OOP. I have tried to learn some MVC, but at this stage I feel it is a bit too advanced for me, and am not quite ready for such a jump. So I was wondering what is a more basic design pattern, to just get started with OOP and getting used to classes. So starting out, how is this usually done? Does each new page have its own class, e.g. products.php, and classes/products.php, and the product.php will just call various methods from the class? Or would there just be a library folder for different classes, and you include whichever class you need to use at a time? Should there be a general class or classes that are called on every page? I guess I am asking what would be a good basic design pattern or structure to get strated with OOP?
  19. Thanks, that seemed a bit better, but still getting an error: Fatal error: Call-time pass-by-reference has been removed in C:\xampp\htdocs\customers\msl\test-nav3.php on line 23
  20. I want to add to an array when each recursive function is called. I have played around with it a few ways, but just getting error after error. This is about where I am up to, it should be enough to work out what I am trying to accomplish. function structure($x, $structure = array()) { $qry = mysql_query("SELECT `parent_id` FROM `categories` WHERE `categories_id`=$x"); $result = mysql_fetch_assoc($qry); $cat = $result['parent_id']; if($cat !=0) { structure($cat, $structure[] = $cat); } echo $cat.' >'; return $structure; } echo structure(22); var_dump($structure); So I am also trying to return the array as well, unsuccessfully. I am not sure how you return an array from a function either. So I would appreciate help on how to add to an array with each recursive function and return the array outside of the function into a useable variable.
  21. I want to be able to update more than one element with an ajax request. This is for a shopping cart. So when someone removes an item, it will update the quantity in the cart element, #cart_quantity, and I want it to also update the remaining items in the cart, by changing the value of their array. So for example: cart_quantity = 4 item1 (array = 0) item2 (array = 1) item3 (array = 2) item4 (array = 3) When I remove item2 from the cart I then want all the array values to be updated (they are contained within a hidden input form), so it should be become; cart_quantity = 3 item1 (array = 0) item3 (array = 1) item4 (array = 2) So in the ajax request I have updated the cart_quantity, and the number of the items in the array. I know I can do this with 2 ajax requests, but is there someway it can be done with just one? For example I have the success part of the ajax query as: success : function(data) { $('#cart_quantity').html(data); } is there someway we can set up something like: success : function(data1) { $('#cart_quantity').html(data1); }, function(data2) { $('#cart_items').html(data2); } Or do you simply have to do two ajax requests? Or are there any other alternatives?
  22. Play around with some table joins, but got nowhere, I think this is out of my depth.
  23. So I have a site with product categories, sub-cats, sub-sub, sub-sub-sub, and even sub-sub-sub-sub. So each category could be up to 5 levels deep. I want to be able to go to a category page and pull all the categories, and sub-cats this category belongs to, to create a sitemap. The database is structured like: category_id | category_name | parent_id | category_url 1 | Clothes | null | clothes 2 | Shirts | 1 | shirts 3 | Designer Shirts | 2 | designer-shirts So if I was to create a sitemap for Designer Shirts, I would want <a href="index.php">Home</a> >> <a href="clothes">Clothes</a> >> <a href="clothes/shirts">Shirts</a> >> <a href="clothes/shirts/designer-shirts">Design Shirts</a> So I want to do a mysql join that will find me all the categories that belong to the current page, and pull the urls (urls also have the parents urls contained too). And the query has to be useable for any hierachy of the category page.
  24. So I am sure it is a common issue, but right now I am having trouble with a slideToggle effect. When I hover over the element, the hidden element slides down, but if I hover over the elemenet several times, and dont move my cursor, the hidden element will slide down, up, down, up, etc several times also. Am I supposed to use stop() function here or something? How can I disable all effects in a queue for this element, and only make the latest one happen.
  25. $(this).$('.remove_cart_item').fadeToggle(); ?? The hidden element is a child of the hover element.
×
×
  • 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.