Here's the case.
I want to make a map system for my turn based strategy game.
the world map will be like travian.. if you know good, but if you don't it's basically like X,Y based map.. but I have trouble in creating ALL of the XY's.. coz let's say I just want to have a maximum XY's of 25, so I have to create from -25,-25 to 25,25 and it's a hell a lot of amount of data.. I tried using excel once then so much dumb errors appeared when I exported it to SQL.. How do people actually do this? It's crazy, Travian has 400 to -400 of XY's and it's so insane if they do it manually, so I know that there's a programmed way, but I have no idea what people even call this to even search the keyword on google..
I am using MySQL btw
Need help how to create mass data in database
Need help how to create mass data in database
Skype: mrvictordiaz
- a_bertrand
- Posts: 1536
- Joined: Mon Feb 25, 2013 1:46 pm
Re: Need help how to create mass data in database
Use excel, but use excel formula to actually create the SQL statement for you, and then copy paste that resulting SQL:
http://www.makewebgames.com/content.php ... ur-content
http://www.makewebgames.com/content.php ... ur-content
Creator of Dot World Maker
Mad programmer and annoying composer
Mad programmer and annoying composer
Re: Need help how to create mass data in database
damn man ur a genius!!!!!!!!!!!!!!!!!!! you gave me the idea now
thanks!!
thanks!!
Skype: mrvictordiaz
- Sharlenwar
- Posts: 523
- Joined: Mon May 28, 2012 7:14 pm
Re: Need help how to create mass data in database
All I did was create a function using PHP to input the data into an array and then into the database. For example:
So what I do here, is I sequence through my map grid that I intend to produce. My maps are 9x9 and so I have it go through each row, and each column and insert that into the DB. You could automate all of your content in this way. Then you would need to tweak each map to your liking. I intend to have an editor that will allow people with appropriate permission to access the maps and change the tiles around.
To make a long story short, I wrote some code to insert the data in.
Code: Select all
$xCoord=0;
$yCoord=0;
for ($yCoord=0; $yCoord < 9; $yCoord++) {
for ($xCoord=0; $xCoord < 9; $xCoord++) {
$data=array(1,$xCoord,$yCoord,1);
$statement=$db->prepare("INSERT INTO mapTiles(mapId,xCoord,yCoord,tileId) VALUES(?,?,?,?)");
$statement->execute($data);
}
}
echo "Coords Inserted into mapTiles<br>";
To make a long story short, I wrote some code to insert the data in.
Deep within the Void of Quasion, a creation.
**My Corner of the Web**
***NEW***GrindFest - My own PHP/MySQL game!
Sharlenwar's Adventures
Torn-City - Massively multiplayer online text based RPG
**My Corner of the Web**
***NEW***GrindFest - My own PHP/MySQL game!
Sharlenwar's Adventures
Torn-City - Massively multiplayer online text based RPG
-
- Posts: 34
- Joined: Thu Mar 20, 2014 9:43 pm
Re: Need help how to create mass data in database
Lacking PHP, I cobbled this together once in an excel cell function on an unused column:
Pretty lame, but it was the quickest an easiest for what I needed.
Code: Select all
="insert into items_122812 values('" &A203 &"','" &B203 &"','" &C203 &"','" &D203 &"','" &E203 &"','" &F203 &"','" &G203 &"','" &H203 &"', '" &I203 &"','" &J203 &"','" &K203 &"','" &L203 &"','" &M203 &"','" &N203 &"','" &O203 &"', '" &P203 &"','" &Q203 &"','" &R203 &"','" &S203 &"','" &T203 &"','" &U203 &"','" &V203 &"', '" &W203 &"','" &X203 &"','" &Y203 &"','" &Z203 &"','" &AA203 &"','" &AB203 &"','" &AH203 &"', '" &AD203 &"','" &AI203 &"','" &AF203 &"','" &AG203 &"');"
- Sharlenwar
- Posts: 523
- Joined: Mon May 28, 2012 7:14 pm
Re: Need help how to create mass data in database
Nothing is lame, we all have different ways of doing the same thing. I figure it is always good to see how others have done it and share. You never know when you might need that one bit of info to help move you along.
Deep within the Void of Quasion, a creation.
**My Corner of the Web**
***NEW***GrindFest - My own PHP/MySQL game!
Sharlenwar's Adventures
Torn-City - Massively multiplayer online text based RPG
**My Corner of the Web**
***NEW***GrindFest - My own PHP/MySQL game!
Sharlenwar's Adventures
Torn-City - Massively multiplayer online text based RPG