View Single Post
  #17  
Old 01-07-2009, 05:00 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by darkslayer2004 View Post
WHERE `name` LIKE '".$id."'

Assuming $id is A-Z, wouldn't that get anything that ENDS with A-Z?
Bit confusing unless you specify what is in the name column and what the $id variable is.

What I was suggesting was something like this (a few example rows):

NPC Code:

id, category, letter, name
1, 1, A, Adventurers Mantle
2, 1, A, Amulet
3, 1, C, Chainmail
4, 1, R, Red Belt of Damage
5, 2, F, Ferry - Dustari to Main


etc etc.

id would be the primary key, and (category, letter) would be an index.

Then you could select like this

PHP Code:
SELECT FROM `itemsWHERE `category` = '1' AND `letter` = 'A' 
Which would in my example get all the items in 'Kingdoms - Armour' that start with an 'A'.

But like I said, it would require you to update the letter column if you ever update the name of the item.
Reply With Quote