Jump to content

Recommended Posts

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 :P if anyone knows how I can get the query to to recognise it as the id field in the database could you help me? ;D thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/176081-query-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.