简体   繁体   English

如何存储 SQL 表 INT 阵营中的 PHP 变量

[英]How to store a PHP variable from a SQL table INT camp

This is my table:这是我的桌子:

数据库表

All I want to do is to obtain the '75' int value from the 'expquim' column to later addition that number into another (75+25) and do an UPDATE to that camp (now it is 100).我要做的就是从'expquim'列中获取'75' int 值,以便稍后将该数字添加到另一个(75 + 25)中并对那个阵营进行更新(现在它是100)。

Foremost, there are dozens of ways to accomplish what you want to do.首先,有几十种方法可以完成您想做的事情。 If you're querying the table, iterating over results and doing some conditional checks, the following will work for you.如果您正在查询表、迭代结果并进行一些条件检查,以下内容将适用于您。 This is pseudo code... Check out the function names and what parameters they require.这是伪代码...查看 function 名称以及它们需要的参数。 $db is your mysqli connection string. $db是您的 mysqli 连接字符串。 Obviously replace tablename with the name of your table.显然将tablename替换为您的表的名称。 The query is designed to only select values that are equal to 75. Modify the query to obtain whatever results you want to update.该查询仅设计为 select 值等于 75。修改查询以获得您想要更新的任何结果。

This should get you close to where you want to be.这应该让你接近你想去的地方。

$query = "SELECT * FROM tablename WHERE idus='1'";
$result = mysqli_query($db, $query);

while($row = mysqli_fetch_assoc($result)) {
    if($row['expquim'] == 75){
      $query2 = "UPDATE tablename SET expquim='".$row['expquim']+25."' WHERE idus='".$row['idus']."' LIMIT 1 ";
      $result2 = mysqli_query($db,$query2);
    }
}

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

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