21 Replies Latest reply on Aug 13, 2010 8:26 AM by kglad

    Need your expertise

    Ron Colmen Level 2

      I need to create a "notice board" in my web page. each notice will be posted to a mysql db. I need my web page to always display the latest notice as the first notice and the rest should be below it according to the posted sequence.

       

      1. How should I do it? (my initial thought was to pull in the data by the PRIMARY ID. But that doesn't seem to work because always when data is been posted to a mysql db it updates the next field not the previous field).

       

      2. Please advice with any important thing which might be helpful in creating my "notice board". This is how I've planned it.

      User input data  >  Updates the mysql >  Data is being pulled in to my webpage using a server side script  >  the latest input data will display on top the rest according to the posted time.

       

      NOTICE at 3.00PM

      text....

      NOTICE at 2.00PM

      text...

      NOTICE at 1.15PM

      text...

        • 1. Re: Need your expertise
          kglad Adobe Community Professional & MVP

          you should be storing a date/time with each notice and using that to determine your textfield's text property.  all programming languages that i know of have something like actionsript's getTime() property so you can order date/times in your server-side script.  or, failing that you can parse the date/time in flash and order the notices using actionscript.

          • 2. Re: Need your expertise
            Ron Colmen Level 2

            Thank you Kglad. 

            • 3. Re: Need your expertise
              kglad Adobe Community Professional & MVP

              you're welcome.

              • 4. Re: Need your expertise
                Ron Colmen Level 2

                I have a dynamic text field to display the NOTICE.Assume there are 200 NOTICE to be pulled in from the mysql and to be displayed in this dynamic text field. How do I write the code to set a format to display the data? The server side script pulls in the data by the datestamp

                 

                1. I need to display all of them in an organized way.

                2. How will the dynamic text box adjust its size according to the number of data? Can this dynamic text be placed inside a scrollplane so all the data could be seen? (is this the way to do this)?

                 

                e.g.

                Heading 1

                Date/Time

                Notice

                //a space

                Heading 2

                Date/Time

                Notice

                //a space

                Heading 3

                Date/Time

                Notice

                 

                receiveLoad.onData = function(src) {

                   var a:Array=src.split(",,");

                   all_notice.text=a[0]+newline+a[1]+newline+a[2];

                //how to have the space and continue this repeatedly?

                  };

                • 5. Re: Need your expertise
                  kglad Adobe Community Professional & MVP

                  using a space for a delimiter isn't going to work if there are spaces in your headings, date/times or notices.  it seems pretty likely there's a space in one of those two.  so you should be using a different delimiter.

                   

                  if you're using a double comma (,,) to delimit the heading from the date/time from the notice, you'll want to use a different delimiter that's not in any of those three blocks.  a triple comma would work, for example:

                   

                  receiveLoad.onData = function(src) {

                  var messageA:Array = src.split(",,,");

                  for(var i:Number=0;i<messageA.length;i++){

                  var msgA:Array = messageA[i].split(",,");

                  if(i==0){

                  all_notice.text = messageA[i][0]+"\n"+messageA[i][1]+"\n"+messageA[i][2]+"\n\n";

                  } else {

                  all_notice.text += messageA[i][0]+"\n"+messageA[i][1]+"\n"+messageA[i][2]+"\n\n";

                  }

                  }

                  }

                  • 6. Re: Need your expertise
                    Ron Colmen Level 2

                    That was interesting! Thanks. But I keep getting

                     

                    "undefined"

                    "undefined"

                    "undefined"

                     

                    "undefined"

                    "undefined"

                    "undefined"

                     

                    How does the triple coma work with php?

                    $query = "SELECT * FROM  notice_bd ORDER BY timestamp ASC";

                    $results = mysql_query($query);

                    while($line = mysql_fetch_array($results))

                    {

                    echo $line["subject"].",,,";

                    echo $line["Notice"].",,,";

                    echo $line["ref"].",,,";

                    echo $line["timestamp"].",,,";

                    }

                    mysql_close($link);

                    • 7. Re: Need your expertise
                      kglad Adobe Community Professional & MVP

                      no.  to use that code in flash you would use something like the following in your php:

                       


                       

                      $query = "SELECT * FROM  notice_bd ORDER BY timestamp ASC";

                      $results = mysql_query($query);

                       

                      $returnS="";

                      while($line = mysql_fetch_array($results))

                      {

                      $returnS .= $line["subject"].",,".$line["Notice"].",,".$line["ref"].",,".$line["timestamp"].",,,";

                      }

                      echo $returnS;

                      mysql_close($link);

                      1 person found this helpful
                      • 8. Re: Need your expertise
                        Ron Colmen Level 2

                        Still it says "undefined". The php pulls the data successfully. But I think there's something wrong in the AS code. Coz when I try to pull just 1 record it displays but when I copy this script it repeats the word "undefined"

                         

                        receiveLoad.onData = function(src) {

                        var messageA:Array = src.split(",,,");

                        for(var i:Number=0;i<messageA.length;i++){

                        var msgA:Array = messageA[i].split(",,");

                        if(i==0){

                        all_notice.text = messageA[i][0]+"\n"+messageA[i][1]+"\n"+messageA[i][2]+"\n\n";

                        } else {

                        all_notice.text += messageA[i][0]+"\n"+messageA[i][1]+"\n"+messageA[i][2]+"\n\n";

                        }

                        }

                        }

                        • 9. Re: Need your expertise
                          kglad Adobe Community Professional & MVP

                          oops, that was my typo:

                           

                           

                           

                          receiveLoad.onData = function(src) {

                          var messageA:Array = src.split(",,,");

                          for(var i:Number=0;i<messageA.length;i++){

                          var msgA:Array = messageA[i].split(",,");

                          if(i==0){

                          all_notice.text = msgA[i][0]+"\n"+msgA[i][1]+"\n"+msgA[i][2]+"\n\n";

                          } else {

                          all_notice.text += msgA[i][0]+"\n"+msgA[i][1]+"\n"+msgA[i][2]+"\n\n";

                          }

                          }

                          }

                          • 10. Re: Need your expertise
                            Ron Colmen Level 2

                            No success as yet! I'm still getting "undefined"

                            • 11. Re: Need your expertise
                              kglad Adobe Community Professional & MVP

                              //what do the following trace() functions reveal:

                               

                              receiveLoad.onData = function(src) {

                              //trace(src);

                              //trace("**********");

                              var messageA:Array = src.split(",,,");

                              //trace(messageA);

                              /trace("**********");

                              for(var i:Number=0;i<messageA.length;i++){

                              var msgA:Array = messageA[i].split(",,");

                              //trace(i+": "+msgA[0]);

                              // as i was typing the above i realized there's another error in my code.  use the following

                              if(i==0){

                              all_notice.text = msgA[0]+"\n"+msgA[1]+"\n"+msgA[2]+"\n\n";

                              } else {

                              all_notice.text += msgA[0]+"\n"+msgA[1]+"\n"+msgA[2]+"\n\n";

                              }

                              }

                              }

                               

                              // if that doesn't work, uncomment the trace functions

                              1 person found this helpful
                              • 12. Re: Need your expertise
                                Ron Colmen Level 2

                                This time it worked!  Thank you Kglad.

                                • 13. Re: Need your expertise
                                  kglad Adobe Community Professional & MVP

                                  you're welcome.

                                  • 14. Re: Need your expertise
                                    Ron Colmen Level 2

                                    How do I avoid the final NOTICE saying "undefined"? (eg. I've got 200 notices and in my swf the 201 notice says "undefined")

                                    • 15. Re: Need your expertise
                                      kglad Adobe Community Professional & MVP

                                      try:

                                       


                                       

                                      receiveLoad.onData = function(src) {

                                      var messageA:Array = src.split(",,,");

                                      messageA.pop();

                                      for(var i:Number=0;i<messageA.length;i++){

                                      var msgA:Array = messageA[i].split(",,");


                                      if(i==0){

                                      all_notice.text = msgA[0]+"\n"+msgA[1]+"\n"+msgA[2]+"\n\n";

                                      } else {

                                      all_notice.text += msgA[0]+"\n"+msgA[1]+"\n"+msgA[2]+"\n\n";

                                      }

                                      }

                                      }


                                      • 16. Re: Need your expertise
                                        Ron Colmen Level 2

                                        Thanks once again Kglad!

                                        • 17. Re: Need your expertise
                                          kglad Adobe Community Professional & MVP

                                          you're welcome.

                                          • 18. Re: Need your expertise
                                            Ron Colmen Level 2

                                            This is how msgA[0] and msgA[1] show. is there a way to remove the time in msgA[1]?

                                             

                                            HEADING1

                                            2010-08-12 07:20:50


                                            I tried doing it in php but without success.

                                             

                                            SELECT DATE_FORMAT(`date`, '%d-%M-%Y') AS required_date FROM my_db

                                             

                                            $query = "SELECT * FROM  my_db ORDER BY timestamp DESC";

                                            $results = mysql_query($query);

                                             

                                            $returnS="";

                                            while($line = mysql_fetch_array($results))

                                            {

                                            $returnS.= $line["subject"].",,".$line["$required_date"].",,".$line["Notice"].",,".$line["link"].",,,";

                                            }

                                            echo $returnS;

                                            mysql_close($link);

                                            ?>

                                            • 19. Re: Need your expertise
                                              kglad Adobe Community Professional & MVP

                                              instead of using msgA[1], use:

                                               

                                              msgA[1].split(" ")[0];

                                              • 20. Re: Need your expertise
                                                Ron Colmen Level 2

                                                GREAT!!!!!!!!  Thank you Kglad. If I have more questions I will come in a new post as I owe you many points. 

                                                • 21. Re: Need your expertise
                                                  kglad Adobe Community Professional & MVP

                                                  you're very welcome!