Jump to content

Problem i just can't solve (database values)


Snooble

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.