Forum Moderators: coopster
All the player's items are stored in the database and every item have a field in the Items-table containing the item's tooltip. This could look something like:
Boots of the Nexus Warden
Soulbound
Feet Cloth
97 Armor
+27 Stamina
+17 Intellect
Durability 35 / 35
Equip: Improves spell hit rating by 18.
Equip: Increases damage and healing done by magical spells and effects by up to 21.
I then want to select the item with i.e. the most Stamina for all the different slots; Head, Chest, Legs etc.
If I write this:
$query = mysql_query("SELECT substring(item_tooltip, LOCATE('Stamina', item_tooltip)) AS maxor FROM roster_items WHERE member_id = '62'") or die(mysql_error()); It returns the following:
Stamina +17 Intellect Durability 35 / 35 Equip: Improves spell hit rating by 18. Equip: Increases damage and healing done by magical spells and effects by up to 21.
But I want for it to show the leading characters also (in this case "+27 " before "Stamina") and then not show anything else after the phrase "Stamina". So it shows "+27 Stamina" and nothing else for the above mentioned item. How do I accomplish this?
And then, secondly how do I then get it to show only the item with the most Stamina after it selected the above?
Hope this makes any sense.
I've tried to search these forums and found something a little along the lines of my problem but haven't been able to adjust them to my needs and I therefore need your help which will be greatly appreciated.
Thanks in advance.
[edited by: eelixduppy at 11:59 pm (utc) on May 25, 2007]
[edit reason] fixed side-scroll [/edit]
I think you'd find it much easier to break the information into separate fields in the database table. If each piece of equipment has the same attributes (armor, stamina, durability, etc) then have a field for each. Then you can use the MAX function in your SELECT statements.
If equipment has different lists of attributes, then it may make more sense to break the attributes into their own table, and relate the attribute list to the equipment item with an identifier. Or you could decide that if an attribute has a value of zero (or any number that is so outrageous that you can pick it out of the mix) then it doesn't apply to the item at hand.
The idea is to break it into bite-sized chunks that are easier to chew. If you like the way your tooltip is and you 'don't want to mess with it' you can leave it as is, and just add the fields which will help you select your data.