sql table how to multliply array of numbers fetched from sql table and stored into array and return

后端 未结 3 1385
难免孤独
难免孤独 2021-01-27 23:55

In a sql table how to multiply array of numbers fetched from sql table

Table like given below

Id         country       Person        Money

1           U         


        
3条回答
  •  野性不改
    2021-01-28 00:50

    Assuming $myDatabase is a mySQLi connection.

    This code is used to get money multiplied by a number.

    $myNumber = 2;
    $qry = "SELECT (Money * {$myNumber}) AS money
        FROM Customers";
    $result = $myDatabase->query($qry, MYSQLI_STORE_RESULT);
    

    And this code is to store all money in array $arrayTotal.

    while ($row = $result->fetch_object()) {
        $arrayTotal[] = $row->money;
    }
    

    Hope this help.

提交回复
热议问题