Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 495
  • Last Modified:

How do I get the last Result only from a amfphp query?

I have a function that inserts a weekly appoinment for a year. One appointment for each week for 52 weeks. So in amfphp I have an insert statement..  It retuns the result 52 times since my flex code submits the query 52 times for each date.  What is the best way to trigger the functions I have in the result function by using the last result only instead of them triggering 52 times?
      $result = mysql_query("INSERT INTO hours(employee,company,street,streetb,city,states,zip,cphone,wphone,emails,notes,types,dates,sth,stm,eth,etm,thours,cname,notesb)VALUES('".$emp."', '".$comp."', '".$street."', '".$streetb."', '".$city."', '".$states."', '".$zip."', '".$cphone."', '".$wphone."',  '".$emails."', '".$notes."', '".$types."', '".$dates."', '".$sth."', '".$stm."', '".$eth."', '".$etm."', '".$thours."','".$cname."','".$notesb."')");    
return mysql_insert_id();
}
public function insWeekly(event:MouseEvent):void{
                
               stat_txt1.text = "Please Wait...";
 
            	 gateway = new RemotingConnection("http://prempack.netfirms.com/amfphpbeta/gateway.php");
            	var responder:Responder = new Responder(onWeekly);
             for(var i:int = 0; i<52; i++){
             var jobDate:Date = jdate.selectedDate;//30 month /14  bi-weekly / 7 weekly
             var dueDate:Date = new Date(jobDate.getTime() + (i*7 * millisecondsPerDay));
            var params:Object = new Object;
             params.emp = emptxtcb.text;
             params.comp = oc_txt.text;
             params.street = astreet.text;
             params.streetb = astreetb.text;
             params.city = acity.text;
             params.states = astate.text;
             params.zip = azipc.text;
             params.cphone = ccphone.text;
             params.wphone = cwphone.text;
             params.emails = cwemail.text;
             params.notes = misctext.text;
             params.types = jtype.text;
             params.dates = dateFormatterb.format(dueDate);
             params.sth = sstime.text;
             params.stm = stimem.text;
             params.eth = eetime.text;
             params.etm = etimem.text;
             params.thours = ttime.text;
             params.cname = cname.text;
            params.notesb = misctextb.text;
            gateway.call( "Recdate.insWeekly",responder,  params.emp,params.comp,params.street,params.streetb,params.city,params.states,params.zip,
             params.cphone,
             params.wphone,
             params.emails,
             params.notes,
             params.types,
             params.dates,
             params.sth,
             params.stm,
             params.eth,
             params.etm,
             params.thours,params.cname,params.notesb); 
            }
            
            }
 
 
public function onWeekly( result : String ) : void
            {
           
            trace(result);
         
            
            if(result != null){
              getWeek();// i don't want this triggered 52 times.
             
            stat_txt1.text = "Jobs Entered!";// i don't want this triggered 52 times.
            
            }
            
           else{
           Alert.show("There is a problem please call for support.","Information!");
           }
            }

Open in new window

0
aduvall
Asked:
aduvall
  • 2
1 Solution
 
Jones911Commented:
So every 52 inserts you want the last ID.

private var insertCount:Number = 0;

if(result != null){
              if(insertCount == 52){
                  getWeek();// i don't want this triggered 52 times.
                  insertCount = 0;
               }else{
                       insertCount++;
               }
             
            stat_txt1.text = "Jobs Entered!";// i don't want this triggered 52 times.
           
            }
0
 
aduvallAuthor Commented:
Could you explain further.  I just want  the trigger for a new function  within the result function to be the last result received. So in this case it would be the 52 result.  For example before I just had amfphp returning the string "ok".  So when it returned I got "ok" 52 times.  There is nothing unique about that so I need to find a way to either only trigger the 52nd time in this case or find a different way.
 public function theResult(result:String){
//on the 52nd result string trigger this function
thisfunction();
}


Thank You for Your help.
0
 
Jones911Commented:
Did you try my code?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now