简体   繁体   English

如何通过PHP从MySQL数据库中的两个不同行计算两个不同值

[英]How to calculate two different values from two different row in mysql database by php

Actually I am creating database on wamp server with the help of php. 实际上,我是在php的帮助下在wamp服务器上创建数据库的。 There is some calculation among some fields.This database for is for lab procurement in which every entry is for new file.Every thing is done but the problem is come when I try to insert a new values for a new file but one value is depend on a value of a previous file. 在某些字段之间进行了一些计算。该数据库用于实验室采购,其中每个条目都针对新文件。做了所有事情,但是当我尝试为新文件插入新值但一个值取决于时,问题就来了在先前文件的值上。 like A(FILE NO) BCD 1 2 3 4 2 5 5 9(D1+C2) 像A(文件编号)BCD 1 2 3 4 2 5 5 9(D1 + C2)

So how does is it possible? 那怎么可能呢? I am new to this language so if there is another way to do this then please tell me. 我是该语言的新手,所以如果还有其他方法可以使用,请告诉我。

You really should use HeidiSQL to create and manage your database, it's much easier.Then you just create a link in php with a php file. 您确实应该使用HeidiSQL创建和管理数据库,这要容易得多。然后,您只需在php中创建带有php文件的链接即可。 As for your question ,yes it is possible quite easy actually : 关于您的问题,是的,实际上可能很容易:

$id=0;//a counter to determine if you had inserted an item
if(isset($_POST['some_item'])){// when a value is set, like adding a new item to your database using the post method
   INSERT....//whatever you want
   $id=$_POST['id'];//the id of the item you just inserted ,which is also the counter
}
if($id!=0)
   //execute whatever code you want

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM