Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. Can you provide some example data? Most likely $show_new_data doesn't contain what you expect.
  2. It's impossible to say exactly what's going on without seeing all of the code, but the model() method returns a different object containing the "TypeOptions" property. As the method returns an object, you can 'chain' the call to the property on the end. The code is effectively the same as: $options_object = Issue::model(); $options = $options_object->TypeOptions;
  3. Adam

    Git fail!

    Power phrasing? :-\
  4. You need to call the DOM method insertBefore on the parent element, passing in the new node and the target node to insert before: <script type="text/javascript"> window.onload = function() { // Create the new node var li = document.createElement('li'); li.appendChild(document.createTextNode('New Child 4')); // Insert before the 4th (index 3) child var ul = document.getElementById('test'); ul.insertBefore(li, ul.children[3]); } </script> <ul id="test"> <li>Child 1</li> <li>Child 2</li> <li>Child 3</li> <li>Child 4</li> <li>Child 5</li> </ul>
  5. Hmm, why notably AJAX? Scope issues can occur in any scope, you just need to reference something that's out of scope.
  6. Adam

    Git fail!

    https://github.com/MrMEEE/bumblebee/commit/a047be85247755cdbe0acce6#diff-1 Ha.. oh dear.
  7. Personally I don't like the idea. Tutorials The last thing the internet needs is yet another tutorial site. Your site offers no more than a basic search engine, but requires more effort and produces a lot less results. While you can register/login, you can't really do anything other than contribute tutorials/snippets. All this site will do at best, is get crawled by Google and force the user to have to go through another website to get to where they actually want to be. Just so that the owner can make a bit of money off the adverts. It only annoys me so much because I'm fed up of clicking a result on Google, only to be taken to some other portal site. I have to spend 10 seconds looking for the right link that isn't some advert trying to trick me, which opens in a new window. Then I have to wait 5 seconds on a full page Ad to click continue, then only to have to close some 3 inch frame at the top. Fairly extreme case of course, but it's an annoying process that seems to be getting worse. If this is just for demonstrating your abilities, or as personal project to develop your skills, obviously that's completely understandable and I take back what I said - although it may be courteous to other users to restrict search engines from indexing the site, or perhaps just the tutorial side of it. Snippets The snippets side of the site I don't really take any stand against. Can be handy I suppose to quickly look up the syntax or structure of a piece of code. There's not much explanation of what the code does though..? It would be far more benefiting to have an explanation of the code, and/or a break-down of what each bit does... I suppose that's down to whoever submits them though I guess. Also some of the code on there at the moment isn't of particularly good quality. Design There's not much to it really. It doesn't seem to quite reach a classy "simplistic" appeal, just looks a little plain/dull... and thin. Would it not be worth widening it, especially for the snippets? The header's pretty dull too. The mark-up code be done better. You make no use of semantic text tags (h1, h2, p, etc.) The class names look bizarrely long, especially for a site of this size. It seems quite excessive too for what's displayed. Usability I feel a little lost sometimes when using the site. Browsing through categories I have no idea what's going to be a snippet or a tutorial. The pagination forces me to click the right arrow 4 times if I want to go to the 5th page. It's also hard to spot the actual link on the tutorial page. -- Apologies if you feel I was overly blunt here, but you asked for a critique. Knowing what's wrong is the way forward!
  8. You should store them as a multi-dimensional array: $items = array( array( 'price' => 3, 'quantity' => 1, ), array( 'price' => 4, 'quantity' => 2, ), array( 'price' => 5, 'quantity' => 3, ), array( 'price' => 6, 'quantity' => 4, ) ); $total = 0; foreach ($items as $item) { $total += $item['price'] * $item['quantity']; } echo $total;
  9. I don't think you've quite considered some of the security issues here. The user PHP runs as, the Apache user, will not have root access to modify config files and reload the Apache config afterwards. It's certainly not recommended to switch the user Apache runs as to the root user, as that would open a lot of security holes. You also need to consider that each user who has an account with you will need their own unix user, with their own permissions, to limit access to the server. I have absolutely no experience with providing web hosting, but you'll need to use scripts/programs hosted on the site to set all of this up. One possible option would be to use bash, or perhaps a more significant language, but certainly not PHP -- definitely the wrong tool for the job, except to call or set-up a request for the server-side scripts. You'll probably also need to use a more sophisticated implementation than the link provided, if you're planning on having a lot of users. Either way you really need to have a good read up on unix users/permissions/bash/security, or hire a sysadmin. It's not fair to provide an insecure service to your users.
  10. Take a look at the jQuery.ajax API. It's very simple to use.
  11. Ha.. Judgement Day, from the Terminator films, you mean? I actually thought that was real
  12. You're quite the conspiracist, CV. What arguments are there for it? An out-of-date calendar, myths..? You mentioned about Nibiru (which people can't seem to decide whether it's 2011 or 2012). "Elenin" was March 15.
  13. Yeah I've read about that, and why none of it's true. Didn't end on 21st April either- that James Cameron's full of sh*t.
  14. Are you referring to QR codes? http://www.google.co.uk/search?q=php+qr+code+generater
  15. That's next December, apparently.
  16. IE6, and I believe 7, do not natively support event.preventDefault.
  17. There certainly is. Have you worked with arrays before? They're basically variables that can hold multiple bits of data, in a set structure. You can use loops to loop through each item in the array and, in your case, works out the pricing totals. You've probably worked with them without realising it, as $_POST is an (associative) array. You access differents bits of data in the structure by specifing the key: $_POST['name_of_key']; You can define a HTML input to post the data as an array, by adding "[]" after the name: Brand:<br> <input name="brands[]" type="int" id="brand1" size="26"><p> So a quick example of how you can loop through each bit of data in the array: $brands = $_POST['brands']; foreach ($brands as $brand) { // Do something with $brand } As you have multiple inputs though you'll need to do it slightly different. Fortunately browsers post input values even if they're blank, so that your structure of post data doesn't alter from what you're expecting. That means you can reliably use the key from one array, to access the same item's value within another array: $brands = $_POST['brands']; $models = $_POST['models']; $prices = $_POST['prices']; $quantities = $_POST['quantities']; foreach ($brands as $key => $brand) { // Do something with $brand // Or $models[$key] // Or $prcies[$key] // Or $quantities[$key] } It also removes the need to manually track the number of items, as you can just use count on one of the arrays. One last thing; you should always check first that a key exists within an array before you try to access it (otherwise you will get a PHP notice). For this you have isset and empty, which are extremely useful functions. Combined with the ternary syntax, you can easily check that an input exists in one line: $brands = !empty($_POST['brands']) ? $_POST['brands'] : array();
  18. To be blunt, I don't think this will be a problem with the browser, but the way you're doing it. Can you show us the code? It's probably just something simple but completely not obvious. What do you mean by this; runs in a terminal?
  19. You can use a multi-dimensional array to keep them altogether, while in separate arrays: $data = array(); while ($row=mysql_fetch_array($query)) { $data[] = $row; } The only small problem with this, is that you're using mysql_fetch_array, which returns the data indexed by both column name and number -- so your array would be twice the size it needs to be. To prevent this you should use either mysql_fetch_row (for numeric array) or mysql_fetch_assoc (for associative array).
  20. Why have you added the toggle() on the end? This works for me: <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $('span.fn_error').hide().slideDown('slow'); }); </script> <style type="text/css"> span.fn_error { display: inline-block; } </style> <span class="fn_error">This is an error</span>
  21. The submit button is only included in the POST data if you actually click it to submit the form. Use a different input to check if the form has been submitted.
  22. Ah yes, missed that before. Well drop the empty call-back function for the second argument; that's not needed and will be generating an error for it's incorrect syntax. Also you may have trouble getting a span to work, as it's not a block-element, so try with a DIV. Finally, you need to set display:none on the CSS class to hide the errors by default - although personally I would hide it with jQuery instead, so that anyone with JS disabled will still see the messages.
  23. Where's your jQuery?
  24. Java != JavaScript
  25. You need to loop through the result data and append() the image HTML for each.
×
×
  • 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.