abi, 2 tane fonksiyon var fonksiyonlari php'de su sekilde cagiriyorum - --- $filler = "((UPSGlobal.ChargeCatCode) in ('ADJ','SHP')) AND (ChargeDescCode in ('001','002','003','013','014','059') ) AND (InvoiceDate = " . $invdate . ") AND "; $sqlTxt = "UPDATE UPSGlobal INNER JOIN tblservice ON UPSGlobal.ChargeDescCode = tblservice.serviceCode SET UPSGlobal.MSIrate1 = (1-getincentive(" . $cont1 . ",[serviceid],[billedweight]," . $revband1 . ",No , zone))*GETRATE(" . $baserate1 . ",[serviceid],[billedweight],[zone]), UPSGlobal.MSIrate2 = (1-getincentive(" . $cont2 . ",[serviceid],[billedweight]," . $revband2 . ",No,zone))*GETRATE(" . $baserate2 . ",[serviceid],[billedweight],[zone]) WHERE (" . $filler . " (chargedesc like '*commercial*'));"; mysql_query($sqlTxt); $sqlTxt = "UPDATE UPSGlobal INNER JOIN tblservice ON UPSGlobal.ChargeDescCode = tblservice.serviceCode SET UPSGlobal.MSIrate1 = (1-getincentive(" . $cont1 . ",[serviceid],[billedweight]," . $revband1 . ",yes , zone))*GETRATE(" . $baserate1 . ",[serviceid],[billedweight],[zone]), UPSGlobal.MSIrate2 = (1-getincentive(" . $cont2 . ",[serviceid],[billedweight]," . $revband2 . ",yes, zone))*GETRATE(" . $baserate2 . ",[serviceid],[billedweight],[zone]) WHERE (" . $filler . " (chargedesc like '*residential*'));"; mysql_query($sqlTxt); ---- fonksiyonlar da burda asagida - getrate ve getincentive. istersen arayabilirsin, nasil yapilacagini soylersen ----- Function getRate(contractID, service, weight, zone, Optional hwt As Boolean) If (weight = "LTR") Then weight = 0 If IsNull(service) Then Exit Function If hwt Then sqlTxt = "SELECT min r.charge FROM tblRateTables r WHERE (((r.contractID)=" & contractID & ") AND ((r.serviceID)=" & service & ") AND ((r.zone)='" & zone & "') AND ((r.weight)<" & weight & ")) GROUP BY weight;" Dim RevIncentive As Variant Set PubCharge = CurrentDb().OpenRecordset(sqlTxt) If PubCharge.RecordCount > 0 Then getRate = PubCharge!CHARGE * weight End If Else getRate = 0 End If If weight > 150 And Not hwt Then tempweight = weight weight = 151 End If sqlTxt = "SELECT r.charge FROM tblRateTables r WHERE (((r.contractID)=" & contractID & ") AND ((r.serviceID)=" & service & ") AND ((r.zone)='" & zone & "') AND ((r.weight)=" & weight & "));" Set PubCharge = CurrentDb().OpenRecordset(sqlTxt) If PubCharge.RecordCount > 0 Then If weight = 151 Then getRate = PubCharge!CHARGE * tempweight Else getRate = PubCharge!CHARGE End If Else getRate = 0 End If End Function Function getIncentive(contractID, service, weight, revenue, resi, zone) If (weight = "LTR") Then weight = 0 If resi = True Then resid = ") AND ((a.residential)= Yes)" Else resid = ") AND ((a.commercial)= Yes)" End If If CBool(zone) Then resid = resid & " AND (maxzone >= " & CInt(zone) & ") AND (minzone <= " & CInt(zone) & "));" Else resid = resid & ");" End If sqlTxt = "SELECT discount FROM tbldiscounts a WHERE (((a.contractID)=" & contractID & ") AND ((a.discountType)='revenue') AND ((a.serviceID)=" & service & ") AND ((a.lowerLimit)<=" & revenue & ") AND ((a.upperLimit)>=" & revenue & resid Dim RevIncentive As Variant Set RevIncentive = CurrentDb().OpenRecordset(sqlTxt) If RevIncentive.RecordCount > 0 Then incentive = RevIncentive!discount Else incentive = 0 End If sqlTxt = "SELECT discount FROM tbldiscounts a WHERE (((a.contractID)=" & contractID & ") AND ((a.discountType)='weight') AND ((a.serviceID)=" & service & ") AND ((a.lowerLimit)<=" & weight & ") AND ((a.upperLimit)>=" & weight & resid Set RevIncentive = CurrentDb().OpenRecordset(sqlTxt) If RevIncentive.RecordCount > 0 Then incentive = incentive + RevIncentive!discount End If sqlTxt = "SELECT discount FROM tbldiscounts a WHERE (((a.contractID)=" & contractID & ") AND ((a.discountType)='base') AND ((a.serviceID)=" & service & resid Set RevIncentive = CurrentDb().OpenRecordset(sqlTxt) If RevIncentive.RecordCount > 0 Then incentive = incentive + RevIncentive!discount End If getIncentive = incentive End Function