Hey all! I am new here... and am in need of some major help! I hope I am posting this in the right forum section, and if I am not... feel free to move it.
I have taken on a project for grabbing item prices from a database for an online game called RuneScape.
If you enter in 1127 into the submit box and hit submit, it will grab the prices of the rune platebody.
Each item which we will be adding to this has its own individual code/id just like the rune platebody. How would we go about turning "item name" into "item id"?
What I want to be able to do is enter in Rune platebody in the text box and to be able to get the price of it. I am thinking this would be an if code... HELP!?
Here is my current code for the page listed above:
If you create an array with the item id as the KEY and the item name as the VALUE, then you can use array_search() to get the ID when you enter a name.
I have one more problem with this. The User is likely to search up lets say rune platebody in many ways...
Rune Platebody
rune platebody
Rune platebody
rune Platebody
I know it is weird... but we are dealing with kids... so would I have to create 4 arrays just for rune platebody? Or can I set it to where caps don't matter?
Edit:
I will also be needing to add hundreds of more items and ids to this. Would I do it under the same array, or make a new array for each item?
Yes, you want to do exactly what jcbones said to do.
Change all the item names in your array to lower case.
Then the kids can have all the fun they want with upper and lower case letters.
So after making the modifications your code would look like this"
Edit: if you read what I had just posted earlier please just ignore it. I found a whole list of items and their ids which will make my job much easier now.
There is one thing I would like to be able to do though...
I would like to be able to grab the item description and the item picture from the runescape web page...
Here is a webpage that you can look at: http://itemdb-rs.runescape.com/viewitem.ws?obj=50
Item = Shortbow (u) ; Description = I need to find a string for this. ; Image = the one to the right... http://itemdb-rs.runescape.com/2659_obj_big.gif?id=50
I know that each image has the same id as the item, so it should be pretty easy calling the image. If you can help me figure the code out that would be great! I have been messing around with the codes for the past hour and can not figure out how to add the image in.
How often do you think that the rune platebody price changes? Your script current goes and grabs this information every single time it runs. Why not , if it ain't against the sites' term of service, just scrap all of it once and store it in a database. This way you won't get in trouble if someone starts to have a problem with all the resources this will consume over time.
__________________ Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
This isn't just grabbing rune platebody. It is grabbing over 3k item prices... and most items change price every hour. It is not against term of use, I have already been in contact with Jagex (the owners) and many other website currently do similar things. (They just won't help me) It uses less of my resources grabbing the prices as needed. If it were to update hourly, I would quickly use up my bandwidth... and so would the other sites I am letting use this code.