Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Acmlmboard support?. |
Acmlm's Board - I2 Archive - Acmlmboard support? - Adding A New Field To The MySQL DB & Updating It At The Same Time | | | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
Elric Chasupa Currently Playing: You Like A Lute. Level: 40 Posts: 67/687 EXP: 440016 For next: 1293 Since: 03-15-04 From: Melniboné Since last post: 6 hours Last activity: 6 hours |
| ||
I'm using a modified version of Weasel's item shop on my board, and I want to do another modification to it. The modification would be tedious to do, so I'm hoping there's some way to make it fast/automated. What I want to do is add an ID to all the items for sale. The only way I can think of to do it is to manually add the field to each table, and then manually assign an ID to each item, one at a time. Is there some php script thingy I can use that will add the ID field, and add a number to it at the same time? Or will I have to do it "by hand"? |
|||
Tuvai Permanently banned for account hacking. Level: 24 Posts: 192/211 EXP: 74894 For next: 3231 Since: 03-15-04 Since last post: 566 days Last activity: 339 days |
| ||
*wonders why the feck you want to work with a field per every item instead of an organised table* | |||
Elric Chasupa Currently Playing: You Like A Lute. Level: 40 Posts: 68/687 EXP: 440016 For next: 1293 Since: 03-15-04 From: Melniboné Since last post: 6 hours Last activity: 6 hours |
| ||
I already have a table. I want to add a new field to the table. | |||
Tuvai Permanently banned for account hacking. Level: 24 Posts: 193/211 EXP: 74894 For next: 3231 Since: 03-15-04 Since last post: 566 days Last activity: 339 days |
| ||
Adding a field for every item still is a bad idea. Either way, you add a field with the following query, I'll let you use it anyway until you find out why adding a field for every item is bad. Adding a 'fieldname' field with varchar(15) type: ALTER TABLE 'tablename' ADD 'fieldname' VARCHAR(15) NOT NULL; Adding a 'fieldname' field with int(5) type: ALTER TABLE 'tablename' ADD 'fieldname' INT(5) NOT NULL; |
|||
Elric Chasupa Currently Playing: You Like A Lute. Level: 40 Posts: 69/687 EXP: 440016 For next: 1293 Since: 03-15-04 From: Melniboné Since last post: 6 hours Last activity: 6 hours |
| ||
I don't think you understand what I'm trying to say. Sorry about that. Let me give you an example: I have my MySQL database, and we'll call it fakedb. Then, I have a table called armor_shop. When I'm looking at it in phpMyAdmin, the top of the page says this: Database fakedb - Table armor_shop running on fakehost Next, I have the following fields: Field Type Null name varchar(255) no price int(11) no def int(3) no spd int(3) no hp int(3) no legend int(3) no Now I want to add a new field, called id, and I want to to enter a value for each item, so that I don't have to click on armor 1, enter the value, click save, click on item 2, enter the value, click save, etc. |
|||
Tuvai Permanently banned for account hacking. Level: 24 Posts: 194/211 EXP: 74894 For next: 3231 Since: 03-15-04 Since last post: 566 days Last activity: 339 days |
| ||
That's just a matter of running update queries in a PHP script, an example (this script assumes the new 'id' field is already there): $item_q=mysql_query("select name from armor_shop order by name"); $new_id=1; while($item=mysql_fetch_array($item_q)){ mysql_query("update armor_shop set id=$new_id where name='".$item[name]."'"); $new_id++; } echo "Done"; This script selects all records from the database, and assigns an ID to every row. |
|||
Elric Chasupa Currently Playing: You Like A Lute. Level: 40 Posts: 72/687 EXP: 440016 For next: 1293 Since: 03-15-04 From: Melniboné Since last post: 6 hours Last activity: 6 hours |
| ||
THANK YOU! That's what I was looking for! Sorry for the confusion caused by my inital post. Sometimes I have a hard time transcribing something from my thoughts to text. |
|||
ErkDog Fuzz Ball Level: 47 Posts: 189/982 EXP: 752190 For next: 14013 Since: 03-15-04 From: Richmond, VA Since last post: 40 days Last activity: 19 days |
| ||
heh I understood what you were asking, but unfortunately I didn't read it until just now | |||
Elric Chasupa Currently Playing: You Like A Lute. Level: 40 Posts: 77/687 EXP: 440016 For next: 1293 Since: 03-15-04 From: Melniboné Since last post: 6 hours Last activity: 6 hours |
| ||
You probably understood it becuase you're as mentally screwed up as I am. As for not reading it until now, well, better late than never. |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Acmlmboard support? - Adding A New Field To The MySQL DB & Updating It At The Same Time | | | |