I'm using PDO in PHP. I've managed to get the first Insert to run but I haven't been able to get the 2nd to. I'm running them on a button click. Here are my basic two SQL Queries.
INSERT INTO MockTable (
`A`, `B`, `C`, `D` )
SELECT `A`, `B`, `C`, `D`
FROM SecondaryTable
ORDER BY A ASC;
UPDATE MockTable
SET
`Name` = From Form,
`Date` = Actual Date
WHERE
`Name` = ''
AND `Date` = '0000-00-00';
And I'm using
.$_POST["Name"].
.date("Y-m-d").
For Name and Date
PHP Code (really messy because I was trying to fix it):
<?php
if(isset($_POST["submit"])){
try {
require '/home4/kylex63/MockUpConfig.php';
$sql = "
INSERT INTO MockTable (`A`, `B`, `C`, `D`)
SELECT `A`, `B`, `C`, `D`
FROM SecondaryTable
ORDER BY A ASC;
UPDATE `MockTable`
SET `Name` = ".$_POST["Name"].", `Date` = ".date("Y-m-d")."
WHERE `Name` = \'\'
AND `Date` = \"0000-00-00\";
";
if ($db->query($sql)) {
echo "<script type= 'text/javascript'>alert('New Record Inserted Successfully');</script>";
}