Jump to content

Recommended Posts

Right this is simple but i wonder if you have another way of me doing it.

 

i have 2 number in a database... column WIN and column LOSE

 

i want to create another column in the database (MYSQL) that subtracts LOSE from WIN and stores it in a column called RATING.

 

can i do this through phpmyadmin?

 

EXAMPLE

WIN = 10, LOSE = 3.
WIN - LOSE = 7
RATING = 7

 

I want it to remain updated...

 

is the only way i can do it by entering a php script on EVERY page of my website (as wins and losses can happen at anytime)?

 

thanks

 

Sam

$rating = $list['w'] + $list['l'];
$sql = "UPDATE users SET rating = '$rating' where id = '$list['id']'"

 

would work fine but it means i must pull info from the database every page load.. can i not create a script in the database itself?

 

like in excel when you can create formulas between cells?

 

Thanks

 

Sam

I know how to include files and order by using sql...

 

but you can only order by a column value...

 

i want to know if i can create a formula between columns in the mysql database?

 

column a minus column b = column c.

 

yes or no?

 

thanks

 

Sam

I guess you update the win/loss everytime the player finishes a game?

 

if so then why don't you calculate the rating everytime you update the win/loss columns and insert the new rating into the rating column?

 

That way it is truly dynamic for each user and you only have to modify the existing code.

 

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.