Jump to content

reading from table or something else


BluwAngel

Recommended Posts

i have problem i have file where i set 2 times (starts and ends)

and i set example from 8:00 to 20:00 all combinations works except starting from 8:00 if i set 8:01 it works but cant find out problem help or idea? (time to 20:00 will work )

 

<?php
session_start();

include '../db_connect.php.';


$title          = $_POST['title'];
$detail       = $_POST['detail'];
$event_date      = $_POST['event_date'];
$id_user      = $_POST['id_user'];

$smjena_od_h   = $_POST['smjena_od_h'];
$smjena_od_min   = $_POST['smjena_od_min'];
$smjena_do_h   = $_POST['smjena_do_h'];
$smjena_do_min   = $_POST['smjena_do_min'];

$vrijeme_od = "$smjena_od_h:$smjena_od_min";
$vrijeme_do = "$smjena_do_h:$smjena_do_min";

function timeDiff($firstTime,$lastTime)
{


$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);


$timeDiff=$lastTime-$firstTime;


return $timeDiff;
}

// converts to hours
$radnih_sati=timeDiff(" $vrijeme_od","$vrijeme_do")/60/60;


//check with other table
$query_settings   = mysql_query("SELECT * FROM settings");
$vrijeme      = mysql_fetch_array($query_settings);
$od_settings   = $vrijeme['rv_otvoreno'];
$do_settings   = $vrijeme['rv_zatvoreno'];
$sati_settings   = $vrijeme['min_rv'];

if ($vrijeme_od<$od_settings or $vrijeme_do>$do_settings or $radnih_sati<$sati_settings){
   echo "Pogrešno uneseni podaci!";
}

else{
//data entry
$insert_event   = 'INSERT INTO events ( title, detail, event_date, id_user, vrijeme_od, vrijeme_do, radnih_sati) 
               VALUES ("'.$title.'", "'.$detail.'","'.$event_date.'", "'.$id_user.'", "'.$vrijeme_od.'", "'.$vrijeme_do.'", "'.$radnih_sati.'")';
            
            
mysql_query($insert_event);
echo "podaci uspješno pohranjeni.";

}

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.