如果相同的帐号超过25000的数量,则抛出错误。否则将其插入数据库中

时间:2015-03-09 05:54:18

标签: php mysql sql

    $dupesql = "select t_id,sum(amount) as amounts from transfer WHERE acc_no='$acc_no1' AND agent_id='$agent_id' group by acc_no having sum(amount) < 25000";

    $duperaw = mysql_query($dupesql);

   if (mysql_num_rows($duperaw) > 0) {
       $sql = mysql_query("INSERT INTO `transfer`(`t_id`, `agent_id`, `agent_name`, `date`, `name`, `phone`, `email`, `tname`, `tphone`, `temail`, `acc_no`, `bank`, `branch`, `code`, `amount`, `comment`, `status`) VALUES (NULL,'$agent_id','$agent_name','$date','$name','$phone','$email','$tname','$tphone','$temail','$accno','$bank','$branch','$code','$amt','$cmmnt','$status')");        
    echo '<script language="javascript">alert("Your Order has been Received \n You will be Notified via SMS/Email when the money is Transfered");window.location="../my.php"</script>';     
    }
    else{
       echo '<script language="javascript">alert("Your Account has been Used more than the limit i.e 5 Times!!!\n Please Contact !!!");window.location="../my.php"</script>'; 
    }

0 个答案:

没有答案