Inersha
06-21-2010, 12:15 PM
Let's say that in a mysql table I have two fields called "score" and "age". I am outputting this information from the database table in to a html table.
I can easily order these in a html table using a mysql_query like:
$result = mysql_query("SELECT * FROM table ORDER BY score")
However, for this table I am creating a new variable from both of these pieces of data. For example:
$score = $row['score'];
$age = $row['age'];
$score_age = $score * $age;
Is it possible to order my html table by this new $score_age variable that is not included in the mysql database? Would it be best to put this $score_age in to the mysql table first? Is it possible to have this $score_age variable automatically inputted in to my mysql table without me having to work it out and input it manually?
I'm new to working with PHP and Mysql and this is my first test project, so I apologize in advance for my poor explanations and coding.
I can easily order these in a html table using a mysql_query like:
$result = mysql_query("SELECT * FROM table ORDER BY score")
However, for this table I am creating a new variable from both of these pieces of data. For example:
$score = $row['score'];
$age = $row['age'];
$score_age = $score * $age;
Is it possible to order my html table by this new $score_age variable that is not included in the mysql database? Would it be best to put this $score_age in to the mysql table first? Is it possible to have this $score_age variable automatically inputted in to my mysql table without me having to work it out and input it manually?
I'm new to working with PHP and Mysql and this is my first test project, so I apologize in advance for my poor explanations and coding.