Fill multiple values php mysql

3538 views php
5

I have an mysqli table like this:-

 id | amount |filled | left
   1| 5.5    |0      | 5.5
   2| 6.7    |0      | 6.7
   3| 4.1    |3.1    | 1

I have an php variable like this:-

 $ar = array(0 => 1, 1 => 2, 2 =>3);

So how do I make an sql query which would make all the ids filled same as amount and left to 0 .

So that table becomes like:-

   id | amount |filled | left
     1| 5.5    |5.5    | 0
     2| 6.7    |6.7    | 0
     3| 4.1    |4.1    | 0

answered question

But this not see easy for me as amounts are different and i need to finish in one query

I'm sorry but I do not see what you mean by 'all the ids filled same as amount and left to 0'. Please show us the output you are looking for. And also what you have tried so far.

1 Answer

13

UPDATE NoOneEverNamesTheirTableInSqlQuestions
SET filled = amount, left = 0;

posted this

Have an answer?

JD

Please login first before posting an answer.