Jump to content

[SOLVED] php / logon / MYSQL database help


thisisnuts123

Recommended Posts

hello guys,

 

I was wondering if this is posible, if so do u guys have good article i can read?

 

i have a user table and i have a main table.

every time a user signs registers it will create information in the user table so for every user there is a new entry ( no problem here)

now when the user logs on to the site it will take information from the main table and randomzie it.. so the information will be changed every time a user refreshes the game..

the prblem is if 2 users are logged on at the same time.. and are accessing the same table.. this will effect how the game works.

 

is there a way work around this? so when the information is changed it does not effect every one and only that one user.

 

so 2 or more users can use the same database

 

 

Thanks in advance

Link to comment
Share on other sites

Add a UserID reference to the main table. As you have it now, I would guess the main table only has one record in it with fields and attributes? For what I suggest, now you will create multiple records, all associated with a UserID. Then, only that User's record in the main table is randomized or changed, and it stays undisturbed until they login again.

 

PhREEEk

Link to comment
Share on other sites

so currently i have

 

a user table which has normal stuff user id/name .password etc etc..

so for eatch user has it;s own record

 

then i have the main table

which is

has:

      |  item | order | itemnum | dat 

 

this table has 16 records..

 

 

so when the user logs in and clicks start it will randomize all the information

so lets say item 1 = hello item 2 = hi item 3 = whatsup

 

it will make item 1 = whats up 2 = hello etc etc..

 

now when the 2nd user logs on.. and cliks starts it;s gona again ramize every thing.. which will now effect the first user..

 

can this be solve with the way u discribed above?

Link to comment
Share on other sites

I'm not really understanding your question entirely.

 

but if you're wondering if randomizing the items for user1 will affect user2, it won't

because you are required to have a primary key for every table you have.

 

the only thing the you are randomizing is the order......I'm assuming

Link to comment
Share on other sites

here is the Main table's structure:

 

 Field         Type              

 set           varchar(50)  

 item          varchar(50)

 order         int(9)                        

 itemnum     int(9)          

 dat       varchar(99)

 

so it looks like this

set    |   item  |  order    | itemnum | dat  

 right     one        5              1           test1

 left      two        4              2           test12

 center   three       3              3          test3

...

...

..,

all the way till 16

 

--------------------------------

user table:

 Field         Type  

 id               int(11)  

 username varchar(64)

 password varchar(32)              

 email varchar(228)                  

 ip varchar(32)                

 fname varchar(32)              

 lname varchar(32)                

 country varchar(32)              

 city varchar(32)                

 gender varchar(32)              

 bday varchar(40)                

 date varchar(32)              

 

 

Link to comment
Share on other sites

hmm..

another way i can think of is.. every time a user sings up i can create a table $userid_table and then insert all the information

since the info is always thee same when the user first starts..

 

but then my db is gona get full with too many tables..

 

or temp table create a table and then drop it when user logs of..

but problem with that is what if they dunt logoff and just close the bowser.. then i will have 2 many tables with no use.

Link to comment
Share on other sites

There is no problem in having 2 or more users use the same table ... let only the same record.

How do you think all these marketing sites work.  Amazon, Tigerdirect, IMDB.  All of their databases are being hit at the same time....most likely 100+ of the same records are being hit at the same time.

 

 

Creating a new table for every user is a common idea a lot people think of.  It never works out.just to warn you.  Unless you have a lot of server money to throw around. 

 

 

You'll be fine in randomizing the order

Link to comment
Share on other sites

ok so lets say right now no one is logged in and the table displayes

 

so it looks like this

set    |  item  |  order    | itemnum | dat 

  right    one        5              1          test1

  left      two        4              2          test12

  center  three      3              3          test3

------------

 

now the first user logs in and starts... the able will get ranmized so if i logon to my sql database i will see new info so the table becomes

 

so it looks like this

set    |  item  |  order    | itemnum | dat 

  right    one        4              1          test1

  left      two        3              2          test12

  center  three      5            3          test3

-----------------------

 

so the first user is working with this..

 

now while the first user is working the 2nd user logs on..

and clicks starts

 

now the table will again recorganize it self to another order. while this is happnong the first user refreshes the page.. now will his order change to new order or stay the same

 

i am not sure how exactly mysql does this. but my belive is the first users order will be changed to new order..

 

and then 3rd user logs on and order again will be changed etc etc..

Link to comment
Share on other sites

that why you was told this

 

Add a UserID reference to the main table. As you have it now, I would guess the main table only has one record in it with fields and attributes? For what I suggest, now you will create multiple records, all associated with a UserID. Then, only that User's record in the main table is randomized or changed, and it stays undisturbed until they login again.

 

PhREEEk

 

each user needs to have there own id..........

Link to comment
Share on other sites

well you're right in one sense

if you set it to order by random for user1 and he refreshes....yes he'll have a new order

 

but user2 logging in won't affect user1, because he's on a different IP

 

 

you may have to organize all of userX's data into an array and just use that

 

 

EDIT: nevermind...I was too late in posting....guess I missed the point somewhere

Link to comment
Share on other sites

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.