-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
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>';
-
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.
-
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.
-
Yup: ORDER BY x ASC, y DESC
-
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.
-
Have you used it recently?
-
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.
-
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.
-
voip03, that would output today's date and the date in a week's time.
-
It's so easy it feels like cheating.. echo date('Y-m-d', strtotime('next saturday')) . ' 10:45AM'; Just be careful when using strtotime.
-
Code to Check Form Field Does not Exceed 100 Characters
Adam replied to webref.eu's topic in PHP Coding Help
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. -
Code to Check Form Field Does not Exceed 100 Characters
Adam replied to webref.eu's topic in PHP Coding Help
Also you can remove max lengths on inputs with the Web Developer add-on (Forms > Remove Maximum Lengths). -
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 }
-
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?
-
Append Ajax Response Text After a specific item
Adam replied to jimmyoneshot's topic in Javascript Help
Can you rephrase that? As I understood it you're asking to create a DIV, without actually creating a DIV? -
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.
-
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.
-
Mmm.. local changes? Can't really comment without seeing them.
-
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.
-
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?
-
Take one guess why nobody is replying to that.
-
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.
-
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.
-
Writing web sites to function with and without JS? Not at all..