Jump to content

Recommended Posts

Hi,

 

This seems like it should be easy, but searching around I haven't been able to figure out how to this yet.

 

I finally got the paypal integration working with my database, and can update tables etc.

So now what I'm trying to do is, when a user purchases 'donor pack 1' via a paypal button.

 

I want to update the database and give them a total of 15 of a particular item.

 

So I need to insert into the items table 15 rows of the item for this player.

 

I can get it to add 1 row, but not sure how to make it insert all 15?

 

Here is what I have now.

 

$updateweapon = mysql_query("insert into items(player_id,item_id,status)values('.$option_name1.','10','unequipped')");

 

Is there a loop or something, where I can hardcode how many rows I wan to insert?

Thank You for responding, and posting how to insert multiple rows.

 

As for the quantity column, this part of the game I didn't develop but maybe I'll give it a try and see how it works.

 

Question tho,  I'm work more with Access and one of the things I always see on the  Access forums is, that you should never have fields for calculated items.  You should get the totals via queries instead.

 

Is MySQL different, and having fields for holding totals of items OK?

 

Thanks!

Chris.

Thank You for responding, and posting how to insert multiple rows.

 

As for the quantity column, this part of the game I didn't develop but maybe I'll give it a try and see how it works.

 

Question tho,  I'm work more with Access and one of the things I always see on the  Access forums is, that you should never have fields for calculated items.  You should get the totals via queries instead.

 

Is MySQL different, and having fields for holding totals of items OK?

 

Thanks!

Chris.

 

Its all about preserving data, because if you ever need those stats or you realize that you've had an error this whole time or any number of reasons and you calculate them before entering them, you haven't preserved the data to fall back on.  That's my view anyway.

Thank You for responding, and posting how to insert multiple rows.

 

As for the quantity column, this part of the game I didn't develop but maybe I'll give it a try and see how it works.

 

Question tho,  I'm work more with Access and one of the things I always see on the  Access forums is, that you should never have fields for calculated items.  You should get the totals via queries instead.

 

Is MySQL different, and having fields for holding totals of items OK?

 

Thanks!

Chris.

 

Its all about preserving data, because if you ever need those stats or you realize that you've had an error this whole time or any number of reasons and you calculate them before entering them, you haven't preserved the data to fall back on.  That's my view anyway.

 

OK,  I'm going to have to think about how to tackle that. 

I'm using ezRPG as my base code, and right now when players add items to their inventory it adds a new row to the items table.

 

Then the rows are deleted etc as the player uses the items.

I'll have to think about how to do something like this, and still have it work with the game.

 

For the time being, I'm going to try the code that was suggested earlier

I'm using this, but it's not working.  It's not adding anything now?  It was working before I added the new code.  Any ideas?

   if ( $item_number == "1") {
                             
                            for($i=0; $i<=15; $i++) {
                                $updateweapon = mysql_query("insert into items(player_id,item_id,status)values('.$option_name1.','10','unequipped')");

                            }


                        }
[code]

Look that why your getting problams man ...........

 

You need to get the code to enter a total like 15, your bern that database out lol,

 

bad code pratice there mate...................

 

if you had 100 players at once your using 1500 table rows your game will crash..................

 

THE CURRENT CODE IS CORRECT CHEEK THAT ==1 THING

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.