Jump to content

timestamp parameter in mysql


localhost1

Recommended Posts

hi

 

i have a condition to test the value of date and time greater than or lessthan the value of date and time in two separate field and indsert or reject insert value in mysql. can i do this by defining the field property as tmestamp or any other. will you please help me with example??

Link to comment
Share on other sites

hi

thanks for your reply

 

in the code given below time inserted in the database field is integer and it compares new inserting value as integer. but what i want to do is insert time in database in the format 2:30 and date as 08-09-2007.But at my present code the time is inserted as 230 not 2:30 n the same thing i want to do with date. i want to compare newly inserting date and time with the existing values in the database n insert if they are not present in the database. so pls give me the idea how can i do this .

the code goes like this

 

if(isset($_REQUEST['timesubmit']))
{	

$fromhr=$_REQUEST['from'];
$tohr=$_REQUEST['to'];
$frommin=$_REQUEST['fromtime'];
$tomin=$_REQUEST['totime'];

$from=$fromhr.$frommin;
$to=$tohr.$tomin;
//echo $from;
$day=date("d");
$month=date("m");
$year=date("Y");

$array = array($day,$month,$year);
$date = implode("-", $array);


if(($from <$to))
{

	$que1= "SELECT * FROM voyance_user_reservation WHERE (user_reserve_time_end > $from AND user_reserve_time_start < $to)";
	//echo $que1;
	$result1 = mysql_query($que1);

	if (mysql_num_rows($result1)!=0)

	 {
	 	$var1=true;
	 	$app->error_display_type=2;
		$app->error("This record overlaps existing time slots");
    		

	 } 
	else
	 {
    		 	$var2=true;
			$que2="insert into voyance_user_reservation values('','".$from."','".$to."','".$date."','','')";
			$result2=mysql_query($que2);
			$app->error_display_type=2;
			$app->error("Time Reserved Successfuly");
	 }


}
else
	{
		$var3=true;
		$app->error_display_type=2;
		$app->error("Start Time Cannot Be Greater Than Or Equal To The End Time");
	}

}

 

code in html goes like this

 

 

<select name="from">
	 <? for($i=1;$i<=24;$i++){?>
	 <option value="<?=$i;?>"><? echo $i;?></option>
	 <? }?>
	 </select>
	 </td>
	 <td><select name="fromtime">
	 <option value="10">10</option>
	 <option value="20">20</option>
	 <option value="30">30</option>
	 <option value="40">40</option>
	 <option value="50">50</option>
	 </select>

 

thank u very much

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.