I think this takes a little more than a simple answer, try reading a php-mysql tutorial:
https://www.w3schools.com/Php/php_mysql_intro.asp
In plain Mysql you just need a “insert into” statement with a select, as explained here. Then you’ll just need to create a php statement to execute this SQL.
solved PHP and MySQL using xampp as web server [closed]