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

                       

        }

       

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.