Porl123 Posted September 30, 2009 Share Posted September 30, 2009 I've got a query that I'm trying to order by doing a sum with one of its fields and one array: $sql = mysql_query("SELECT `type` FROM `items` WHERE `username` = '".$username."' ORDER BY (($items[id]['price'] / 50) * (50 - `damage`)) DESC"); The problem is with the: $items[id]['price'] The $items is an array although the id for the [id] is the id of the item it's currently selecting with the query, but thinking about it it's obviously just going to see that [id] as its own field, rather than the field in the database Sorry if I'm not explaining this very well but I'm crappy with the terminology if anyone knows how I can get the query to to recognise it as the id field in the database could you help me? thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/176081-query-problem/ Share on other sites More sharing options...
gluck Posted October 2, 2009 Share Posted October 2, 2009 You can't do that. What are you planning to order the result set by? Can you explain what you want from the query? Quote Link to comment https://forums.phpfreaks.com/topic/176081-query-problem/#findComment-929278 Share on other sites More sharing options...
Mchl Posted October 2, 2009 Share Posted October 2, 2009 Perhaps an example of your data and a result you'd like to get would help us understand. Quote Link to comment https://forums.phpfreaks.com/topic/176081-query-problem/#findComment-929288 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.