I am doing some work in php with prepared statements. My task is to first select some data from one table and then insert the data into another table. How can I use while loop in prepared statement to insert the records?
Here is the code:
stmt=$db->prepare("SELECT userid, order_number, balance from plus_wallet limit 0,3");
$stmt->execute();
$stmt->bind_result($userid, $orderid, $balance);
while($stmt->fetch()) {
$stmt1=$db->prepare("INSERT INTO `plus_user_wallet`(`userid`, `balance`, `update_time`) VALUES (?,?, NOW() + INTERVAL 45000 second)");
$stmt1->bind_param('ss' , $userid, $balance);
$stmt1->execute();
$stmt1->close();
$stmt->close();
}