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

Posted on 2009-02-11
Last Modified: 2013-12-12
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("");

            	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;

    = acity.text;

             params.states = astate.text;

    = 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;

   "Recdate.insWeekly",responder,  params.emp,params.comp,params.street,params.streetb,,params.states,,















public function onWeekly( result : String ) : void






            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.





 "There is a problem please call for support.","Information!");



Open in new window

Question by:aduvall
    LVL 19

    Expert Comment

    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;
                stat_txt1.text = "Jobs Entered!";// i don't want this triggered 52 times.

    Author Comment

    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

    Thank You for Your help.
    LVL 19

    Accepted Solution

    Did you try my code?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now