I´m trying to insert a current SELECT-Statement into an Database table with an PHP-variable. It works by this way without the variable:
mysql_query("INSERT INTO table (column) SELECT column FROM table1");
Did anyone have a idea how I can fix it?
PHP: 5.3.10 and mysql-databse
You can use mysql_insert_id() to get the last inserted ID value and try insert query separately.
<?PHP
$lastId = mysql_insert_id();
$query = mysql_query("Your Select Query with $lastId");
?>
try this
$sample="SELECT column FROM table1"; // your select query
$query="INSERT INTO `table` (column) $sample";
mysqli_query('database connection code',$query);
Let me know if any problem arises.