Table table1
id user_name numbers wtime
1 Jack 12 2017-08-19 10:08:28
3 Andy 34 2017-08- 19 10:08:37
4 Lulu 24 2017-08-19 10:09:04
I want to update the numbers column in table1 according to the formula; for example, the numbers column is multiplied by 0.01.
The following table should be drawn:
id user_name numbers wtime
1 Jack 12.12 2017-08-19 10:08:28
3 Andy 34.34 2017-08-19 10:08:37
4 Lulu 24.24 2017-08-19 10:09:04
I have been writing for a long time and I can’t figure out a way. Please help me.
玛莎拉蒂2017-08-20 23:39:20
$sql="select * from table1";
$result=mysqli_query($conn,$sql);
while($rs=mysqli_fetch_array($result)){
$uid=$rs['id'];
$num=$rs['numbers']+1;
echo "$num"."<br />";
$sql="UPDATE table1 SET numbers = $num where id=$uid";
$sql=mysqli_query($conn,$sql);
ringa_lee2017-08-19 11:49:38
select finds the data, then traverses the data, and performs the operation of multiplying by 0.01 in foreach
I don’t know if you can understand it like this, I hope it can help you