[英]SQL Query, within php
I currently have a query 我目前有一个查询
$query = "SELECT * FROM routes ORDER BY
id
DESC LIMIT 8;"; $ query =“ SELECT * FROM路由ORDER BYid
DESC LIMIT 8;”;
And that works all wonderfully. 这一切都很棒。
I have table columns 我有表格列
id int(10)
name varchar(45)
base varchar(16)
econ int(6)
location varchar(12)
x int(2)
y int(2)
galaxy int(2)
planet int(2)
comment varchar(100)
ipaddress varchar(45)
and on the page when this segment of php is called i will have the econ,X,Y,Galaxy,and planet of another entry 并在页面上调用此段php时,我将拥有另一个条目的econ,X,Y,Galaxy和Planet
then i want to display the entry is the database(like i do at the moment) BUT i want a new column to be displayed that is not in the DB, this new column is to be the output of a calculation.. the calculation is to be 然后我想显示条目是数据库(就像我现在所做的那样),但是我想显示不在数据库中的新列,该新列将作为计算的输出。成为
Sqrt(min. Economy) x ( 1 + Sqrt(Distance)/75 + Sqrt(Players)/10 )
Sqrt(88) x ( 1 + Sqrt(23)/75 + Sqrt(23)/10 ) = 15 cred./h
players is another variable that is already available in my page 玩家是我页面中已经可用的另一个变量
Distance is a function of the 2 galaxys unless there the same when its a function of the 2 x's and y's unless there the same and then its a function of the 2 planet integers 距离是2个星系的函数,除非它是2 x和y的函数,除非存在相同,然后是2个行星整数的函数
here is the page i talk of..i will add a new button to compare.. thats the new function that i want to compare the given value with existing values. 这是我谈论的页面..我将添加一个新按钮进行比较..多数民众赞成在新的功能,我想比较给定值和现有值。 http://www.teamdelta.byethost12.com/trade/postroute2.php http://www.teamdelta.byethost12.com/trade/postroute2.php
You can just calculate in your query like this: 您可以像这样在查询中进行计算:
$query = "SELECT (Sqrt(min. Economy) x ( 1 + Sqrt(Distance)/75 + Sqrt(Players)/10 ) Sqrt(88) x ( 1 + Sqrt(23)/75 + Sqrt(23)/10 ) = 15 cred./h) as `Distance`, * FROM routes ORDER BY id DESC LIMIT 8;";
Use as for naming your calculation so its become a column and use * to get the other fields. 用于命名您的计算,以使其成为一列,并使用*获得其他字段。
After the query you store the results into an array. 查询后,您将结果存储到数组中。 You could parse the array adding an item containing the calculation that you wrote. 您可以解析数组,添加包含您编写的计算的项目。 If you want more details you should past here the array 如果您想了解更多详细信息,则应将数组放在此处
-- -
dam 坝
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.