Jump to content

MySQL PHP and AJAX (I'm lost)


wyght

Recommended Posts

Hi

 

I have not written code for about 6 years so I am a greenie again. I built a MySQL DB and populated it with 400 different quotes my son needs to memorize for school. I then connected to the DB with PHP and placed each record into a Class that I also built. I can display the entire set on the web page with no problem but I want to rotate through the records one at a time. I would like to do this using AJAX but do not know the most intelligent way to do it and do not have a clue where to go to learn how. I have searched on google.com for days but not found anything that helps me.

 

Is there a place I can go to learn how to grab the entire 400 records, store them in an array, and then using AJAX place them on the web page one record at a time with the ability to go forward or backwards through the set of records?

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/248351-mysql-php-and-ajax-im-lost/
Share on other sites

OK never mind, I finally figured it out wasn't all that hard just different the below seems to work fine.

 

i=0; $j=0;

    echo "

    <script type=;text/javascript'>

      var myrecord=new Array;

    </script> 

    ";

 

foreach($my_db_record as $op)       

        { 

                echo "

                        <script type=;text/javascript'>

                          var myrecord=new Array;

                      ";

                   

            echo "myrecord[".$i."][".$j++."]='".$op->id;

            echo "myrecord[".$i."][".$j++."]='".$op->scr;

            echo "myrecord[".$i."][".$j++."]='".$op->mem_book;

            echo "myrecord[".$i."][".$j++."]='".$op->mem_ref;

            echo "myrecord[".$i."][".$j++."]='".$op->mem_prompt;

            echo "myrecord[".$i."][".$j++."]='".$op->mem_verse."</script>";   

                       

        }

       

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.