0
<?php
    include_once("connect.php");
    if(isset($_POST))
    {
        $sno=$_POST['sno'];
        $start_date=$_POST['start_date'];
        $end_date=$_POST['end_date'];
        $amount=$_POST['amount'];
        $lease_id=$_POST['lease_id'];
        if($lease_id == 0){
            $lease_id=1;
        }
        $calendar_type=$_POST['calendar_type'];
        $rph=$_POST['start_date']." - ".$_POST['end_date'];
        $sql="INSERT INTO tbl_lease_details(lease_id,sno,start_date,end_date,amount,calendar_type,rph,stat) VALUES ('$lease_id','$sno','$start_date','$end_date','$amount','$calendar_type','$rph','not_paid')";

        $result=mysql_query($sql);
        if($result){

            echo "successfully inserted";
        }
    }
    mysql_close($rs);
    mysql_close($connect);
?>

I need to add a "loader" in order to make some delay before inserting into database. I tried my best but I couldn't, please help me to solve this issue.

5
  • You can use sleep. The better question is why would you want to delay the insert? And stop using mysql_*, they're deprecated. Commented Oct 4, 2017 at 11:51
  • you can use javascript function. window.setTimeOut() Commented Oct 4, 2017 at 11:51
  • @Andrew where can i use sleep?, Im a beginner Commented Oct 4, 2017 at 11:54
  • @SubhabrataMondal how to include setTimeOut() inside that? Commented Oct 4, 2017 at 11:56
  • <html> <head> <title></title> <script type="text/javascript"> function test(){ setTimeout(function(){ alert("Hello"); }, 3000); } <?php echo "test();"; ?> </script> </head> <body> </body> </html> Commented Oct 4, 2017 at 12:00

1 Answer 1

3

In php we can add dealy using sleep function. please check below code

     echo date('h:i:s') . "<br>";

    //sleep for 5 seconds
    sleep(5);

    //start again
    echo date('h:i:s');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.