increment date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dujed
Forum Newbie
Posts: 9
Joined: Thu Mar 30, 2006 6:49 am

increment date

Post by dujed »

Can you you help me please,I have following code:

do
{
$sql='INSERT INTO rezerv (date,ime) VALUES ($_POST["date1"],$_POST["ime"])';
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Success!";
********in this place I need increment "date1" for 1 day********
*******format for date is year,month,day******************
}

while (($_POST["date1"]) != (($_POST["date2"])

thanks!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: increment date

Post by RobertGonzalez »

Please use PHP tage when posting PHP code. Thanks. This is how it should look. See comments at the bottom...

Code: Select all

<?php
do
{
	  $sql='INSERT INTO rezerv (date,ime) VALUES ($_POST["date1"],$_POST["ime"])';
       if (!mysql_query($sql,$con))
         {
           die('Error: ' . mysql_error());
         }
     echo "Success!";
********in this place I need increment "date1" for 1 day********
*******format for date is year,month,day******************
}

  while (($_POST["date1"]) != (($_POST["date2"])
?>
Have you looked at the mysql date() function? Or how about the PHP strtotime() function coupled with the PHP Date() funtion?
Post Reply