using sprintf
Posted: Fri Oct 18, 2013 8:14 am
I am using some code I found online it works great and I have inserted all my db information for the table but its not inserting and I don't know what else to try. I tied to call the query and run error chk and all is find for errors and all but just wont insert into the db so I thought someone here would see something I am not seeing.
What this does.. is when a user chooses a date in the future it will insert that many records into the table for that many days.
any help on this issue would be great
What this does.. is when a user chooses a date in the future it will insert that many records into the table for that many days.
Code: Select all
// sample data from user input:
$start_date = date('Y-m-d');
$end_date = $_POST['end'];
$surftime = date('H:i:s');
// create values for each date:
$startTime = strtotime($start_date);
$endTime = strtotime($end_date);
$values = array();
for($time = $startTime; $time <= $endTime; $time = strtotime('+1 day', $time))
{
$thisDate = date('Y-m-d', $time);
$values[] = "(null,{$_SESSION['admin_id']}, $start_date, $surftime, 15,15, yes)";
}
// build the actual query:
$query = mysql_query(
"INSERT INTO surfstat (id,usrid, date, time, pgviews, num ,received_pay) VALUES\n%s", implode(",\n", $values));