localhost1 Posted September 8, 2007 Share Posted September 8, 2007 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?? Quote Link to comment https://forums.phpfreaks.com/topic/68453-timestamp-parameter-in-mysql/ Share on other sites More sharing options...
darkfreaks Posted September 8, 2007 Share Posted September 8, 2007 code please? Quote Link to comment https://forums.phpfreaks.com/topic/68453-timestamp-parameter-in-mysql/#findComment-344155 Share on other sites More sharing options...
localhost1 Posted September 8, 2007 Author Share Posted September 8, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/68453-timestamp-parameter-in-mysql/#findComment-344166 Share on other sites More sharing options...
Barand Posted September 8, 2007 Share Posted September 8, 2007 You can't compare dates dd-mm-yyyy format. You need yyyy-mm-dd Quote Link to comment https://forums.phpfreaks.com/topic/68453-timestamp-parameter-in-mysql/#findComment-344200 Share on other sites More sharing options...
localhost1 Posted September 10, 2007 Author Share Posted September 10, 2007 hi thanks for reply but will u please give me an example how timestamp variables are compared?? thanks Quote Link to comment https://forums.phpfreaks.com/topic/68453-timestamp-parameter-in-mysql/#findComment-345164 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.