need help on a datetime query submission
Posted: Sun Jan 08, 2006 6:18 pm
hawleyjr | Please use
hawleyjr | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi,
I have some code i am trying to modify which inserts a booking into a mysql database. People book in blocks of 5 so there should be 5 bookings automatically created at the same time every 7 days. The date needs to be submitted in YYYY-MM-DD hh:mm:ss format. If i comment out the ($date = date("Y-m-d h:i:s", mktime($hour, $min, $second, $month, $day + 7, $year));) line there are 5 records created all with the same date and when i uncomment it the code doesnt work so Im pretty sure this is the line playing up. I've tried playing around with it but have had no luck, any help would be gratefully recieved.
Thanks,
RobCode: Select all
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$date = GetSQLValueString($_POST['lesson_datetime'], "date");
for ($i = 0; $i < 5; $i++)
{
$year = substr($date, 0, 4);
$month = substr($date, 5, 2);
$day = substr($date, 8, 2);
$hour = substr($date, 11, 2);
$min = substr($date, 14, 2);
$second = substr($date, 17, 2);
$date = date("Y-m-d h:i:s", mktime($hour, $min, $second, $month, $day + 7, $year));
$insertSQL = sprintf("INSERT INTO booking (bookingid, teacherid, studentid, roomid, lessontypeid, lesson_datetime, cancel) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['bookingid'], "int"),
GetSQLValueString($_POST['teacherid'], "int"),
GetSQLValueString($_POST['studentid'], "int"),
GetSQLValueString($_POST['roomid'], "int"),
GetSQLValueString($_POST['lessontypeid'], "int"),
$date,
GetSQLValueString($_POST['cancel'], "text"));
mysql_select_db($database_connection, $connection);
$Result1 = mysql_query($insertSQL, $connection) or die(mysql_error());
}
}hawleyjr | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]