Jump to content

[SOLVED] calculations within a field


bhavin_85

Recommended Posts

hey guys

 

i have a field which is float, it stored the price of an item, i need to create another field called points which times the price by 0.1 and stores that value.

 

how would i do this? can the sql database do it itself or would i need to create a function in php that will convert it then store the points?

 

cheers

 

Link to comment
https://forums.phpfreaks.com/topic/41634-solved-calculations-within-a-field/
Share on other sites

ok so i guess from what ur saying ill have to write the code in my form which enters the info into that database, ill have a go at it

 

What thorpe is suggesting is to let your SQL do it. I agree with him because you would simply have to write a single query to update all the fields. Once you add your new field, just run the query he posted above, and it will update the whole table for you.

You can run mysql from .php pages.

 

Just set the query into a variable like so:

 

$sql = "PUT QUERY HERE (e.g. SELECT BLAH FROM BLAH/UPDATE diggerydoo)";
mysql_query($sql) or die ("Couldn't execute $sql: " . mysql_error()); 

 

put that in your page and you'll see, replace "PUT QUERY HERE" with the query (rolls eyes)

 

Snooble

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.