Answer the question
In order to leave comments, you need to log in
How to limit UPDATE input to current date only?
We write the generated number to the table.
Actually, everything is fine, only I need to write only the current date and not generate all the previous ones, I need to fill them with correct numbers.
I show the whole file because it is small.
<?php
require 'connect.php';
$total = 1600000;
$random = array(
'workweek' => array(-4,7),
'holiday' => array(-16,-4)
);
$q = mysql_query("SELECT * FROM `betaintranet`.`ad_stat_cleaned`");
while($row = mysql_fetch_assoc($q))
{
$now = time();
$daysInMonth = date('t', $now);
$dayOfWeek = date('w', mktime(0,0,0, date('m', $now),date('d', $now), date('y', $now)));
$isHoliday = $dayOfWeek == 6 || $dayOfWeek == 0;
$rand = $isHoliday ? $random['holiday'] : $random['workweek'];
$rand = rand($rand[0],$rand[1]);
$daily = $total / $daysInMonth;
$part = round($total / $daysInMonth / 100 * $rand);
$modification = round($row['modification'] + ($daily + $part) / 24);
$sql = "UPDATE `betaintranet`.`ad_stat_cleaned` SET `betaintranet`.`ad_stat_cleaned`.`modification` = '{$modification}' WHERE
`betaintranet`.`ad_stat_cleaned`.`bid` = '{$row['bid']}' AND
`betaintranet`.`ad_stat_cleaned`.`date` = '{$row['date']}'";
mysql_query($sql) or die(mysql_error());
}
Answer the question
In order to leave comments, you need to log in
$q = mysql_query("SELECT * FROM `betaintranet`.`ad_stat_cleaned` WHERE `date`='".date("Y-m-d")."'");
while($row = mysql_fetch_assoc($q))
{
...
}
UPDATE to copy the whole show into modification
mysql_query("UPDATE `betaintranet`.`ad_stat_cleaned` SET `modification`=`show` WHERE `date`='".date("Y-m-d")."'") or die(mysql_error());
mysql_query("UPDATE `betaintranet`.`ad_stat_cleaned` SET `modification`=`show`") or die(mysql_error());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question