Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. You're using a single quote within a single quote string. You need to concatenate the variable into the string: echo '<tr><td>' . $row['player'] . '</td>';
  2. You can also cut out the inevitable second call to getElementById in that situation with: var el; if (el = document.getElementById('...')) { // ... }
  3. Okay, have more time to look at this now. I'm a little unsure what you're trying to do though. Can you explain the relationship the junction table has with the others? You seem to be selecting from it and joining it on again later. Is this intentional? I think it would make more sense to select from the master product table, and join on the additional data. Try this: select mprid, min(feedprice) feedprice from ( select m.product_id as mprid, case when f.product_sale_price is not null then f.product_sale_price else f.product_price end feedprice from tblmpr m join tblmpr_mpc_junction j on (m.product_id = j.mprid) join tblfeeds f on (j.product_xmlid = f.product_xmlid) order by feedprice ) as x; I've removed the back-ticks and given tables an alias, because it was quite hard to read before. If you wish to retrieve more columns you'll need to select them within the inner query, assign them an alias, then select that alias within the outer query. Or alternatively you can use "select *, min(feedprice)" in the outer query.
  4. I only have time for a quick glance over it at the moment, but within the outer select you need to select the aliases you defined within the sub-query. The outer query has no knowledge of the table names and such, it's just 'handed up' if you like, the aliases. Remember you're not selecting from a table, you're selecting from a result set.
  5. Yup: ORDER BY x ASC, y DESC
  6. I realised looking back at this, I made a mistake with the previous SQL I gave you. It would always return the details of the first child product, but the lowest price of them due to the min() use. So fixing that, and incorporating the multiple price columns with a "CASE" statement, you can use this: select m_id, m_title, c_id, c_title, min(cost) from ( select m.id as m_id, m.title as m_title, c.id as c_id, c.title c_title, case when c.sale_price is not null then c.sale_price else c.price end cost from master_products m join child_products c on (m.id = c.parent_id) order by cost ) as x; As the master and child product tables have some of the same names (or at least they do in the schema I was playing about with), the aliases are needed to prevent any ambiguity when selecting from the sub-query. Edit You can add a further ORDER BY statement after the sub-query by the way.
  7. Have you used it recently?
  8. You really need to get the theory right in your head before you try to code it. You need to know what impact a single click will have, and how many it will take to visibly change the size. Also consider the math behind it, because sizes are going to be relative to the absolute total number of clicks.
  9. A named submit button's value won't be submitted unless you actually click it. What does the PHP code look like? If "vote2.php" only handles one form, then just check if any POST data was submitted to detect the submission: if (!empty($_POST)) { If it handles multiple forms, check if one of the required fields is not empty like above.
  10. voip03, that would output today's date and the date in a week's time.
  11. It's so easy it feels like cheating.. echo date('Y-m-d', strtotime('next saturday')) . ' 10:45AM'; Just be careful when using strtotime.
  12. Not to pick nits but you put "as well", which suggests an alternative. "As well as" means both. Easy mistake to make both ways though, and if anything will hopefully discourage the OP from ever relying on maxlength.
  13. Also you can remove max lengths on inputs with the Web Developer add-on (Forms > Remove Maximum Lengths).
  14. Adam

    Confused!

    You're comparing an object, which will return true as it exists (and isn't null or undefined). Think of it more like this: if (object) { // object exists } Whereas a normal boolean comparison is: if (boolean) { // boolean is true }
  15. This is really a job for Flash or JavaScript (much preferably the latter). PHP can't dynamically update the timer without another request (refreshing the page), as it's executed on the server. Do you have any experience with JS?
  16. Can you rephrase that? As I understood it you're asking to create a DIV, without actually creating a DIV?
  17. Adam

    Confused!

    You're testing against the Boolean object itself, not the boolean value. The object contains a toString() method that returns the boolean value when you use it in a string context.
  18. You can select the min() priced child product, grouped by the parent ID and joined onto the master product table to get all the data you need within a single query. I had to guess at your schema but should give you a good idea: select m.id, m.title, c.id, c.title, min(c.price) from master_products m join child_products c on (m.id = c.parent_id) group by c.parent_id order by c.price; You'll probably want to give the selected columns an alias.
  19. Mmm.. local changes? Can't really comment without seeing them.
  20. It isn't "correct" to do it that way, but I agree there are situations where it's not worth it to some degree. Of course that's only for minor functionality though; navigation and transactional functionality for example should never be impacted! The main reason I made a point of saying it though is that this is a learning community, and we should aim to teach everybody the right way, even if they choose not to follow it later.
  21. Could you not wrap the SELECT statement within another SELECT statement that handles the ordering? select * from ( ... ) as p order by p.price; Edit Actually I'm not sure what you're doing. I don't understand why you can't order them, without even wrapping the select statement, if you have a price?
  22. Take one guess why nobody is replying to that.
  23. I can recall something similar, but about cookies. I can't think of any sites off of the top of my head but I'll let you know if I do. The site you linked to is largely accessible without JS, just certain features. I'm not saying there aren't sites out there that have done well without complete non-JS support, I'm just trying to say the correct way of doing it.
  24. As mentioned, Facebook has the light-weight "mobile" version that allows you to use the site with JS disabled. I imagine Twitter and YouTube will have something similar, but will need to verify that later. Edit Was actually this topic I mentioned about Facebook's mobile site. While there aren't that many users that have JS disabled, given how easy it is to cater both ways I don't see any excuse not to. At work everything we write has to work in both situations, and for all of the major browsers including IE6. Those few users that you turn away could turn into some of your most active users, and bring more users to the site. You never know.. @ZulfadlyAshBurn Write your site without AJAX to start with. Have every link function like normal. Assuming you're using a framework like jQuery, you can easily detect an AJAX request with the HTTP_X_REQUESTED_WITH header. If this is present, simply don't include the header and footer in the output. You can then use selectors to target forms, links, etc. and change the submission, click, etc. event to go through your AJAX handler. If the user has JS disabled, they'll just navigate around as usual.
  25. Writing web sites to function with and without JS? Not at all..
×
×
  • 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.