Reputation: 1
Everything here is working except the UPDATE command... The INSERT works fine but alas, I'm stuck.
$queryLastDateArray = "SELECT date FROM schedule ORDER BY ID DESC LIMIT 1";
$lastDateArray = mysql_query($queryLastDateArray);
while($row = mysql_fetch_array($lastDateArray))
{
$lastDate = $row['date'];
}
$lastDatePlusOne = date("Y-m-d", strtotime("+1 day", strtotime($lastDate)));
$newDatesArray = GetDays($lastDatePlusOne, $_POST[date]);
$i = 0;
while($i < count($newDatesArray))
{
if ((date('D', strtotime($newDatesArray[$i]))) == 'Fri')
{
$insDate = "INSERT INTO schedule (date) VALUES ('$newDatesArray[$i]')";
$result = mysql_query($insDate);
$insEmp = "UPDATE schedule SET schedule.jakes = schedule_default.jakes FROM schedule, schedule_default WHERE schedule.date = '$newDatesArray[$i]' AND schedule_default.ID = '5'";
$result2 = mysql_query($insEmp);
}
$i++;
}
Upvotes: 0
Views: 95
Reputation: 31665
Multiple table UPDATE
syntax is:
UPDATE schedule, schedule_default
SET schedule.jakes = schedule_default.jakes
WHERE schedule.date = '$newDatesArray[$i]'
AND schedule_default.ID = '5'
Upvotes: 1
Reputation: 55449
Try writing the update like this:
"UPDATE schedule SET schedule.jakes = (SELECT schedule_default.jakes FROM schedule_default WHERE schedule.date = '$newDatesArray[$i]' AND schedule_default.ID = '5')";
Upvotes: 2