Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7955299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:41:00+00:00 2026-06-04T03:41:00+00:00

What I’m trying to do is loop through the 2 urls i have in

  • 0

What I’m trying to do is loop through the 2 urls i have in my db. So far I’ve gotten it to work for the first row but I need it to loop through both of the rows. As of right now it is only looping through the first url in the db two times. I tried making ‘#jquery_jplayer_1’ a class but that still doesn’t seem to work. Any ideas or help?

<!DOCTYPE html>
<html lang="en">
<head>
<?php include("vh.php"); ?>
<?php $query = $this->db->query("SELECT * FROM music");
      foreach ($query->result() as $row) {
?>
        <!-- Example code to create a simple player using jPlayer 2.1.0 -->

        <!-- Skins are defined in CSS. Uncomment the following CSS reference and comment out the one below it to switch skins -->

        <!--<link href="http://jplayer.org/latest/skin/blue.monday/jplayer.blue.monday.css" rel="stylesheet" type="text/css" />--> 
        <link href="http://jplayer.org/latest/skin/pink.flag/jplayer.pink.flag.css" rel="stylesheet" type="text/css" />

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>    
        <script type="text/javascript" src="http://jplayer.org/2.1.0/js/jquery.jplayer.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {

                $(".jquery_jplayer_1").jPlayer({
                    ready: function(event) {
                        $(this).jPlayer("setMedia", {
                            mp3: "<?=$row->songURI?>",
                        });
                    },
                    swfPath: "http://www.jplayer.org/2.1.0/js",
                    supplied: "mp3"
                });
            });
        </script>

    </head>
    <body>
        <div class="jquery_jplayer_1" class="jp-jplayer"></div>

        <div id="jp_container_1" class="jp-audio">
            <div class="jp-type-single">
                <div class="jp-gui jp-interface">
                    <ul class="jp-controls">

                        <!-- comment out any of the following <li>s to remove these buttons -->

                        <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
                        <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
                        <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
                        <li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>
                        <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>
                        <li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>
                    </ul>

                    <!-- you can comment out any of the following <div>s too -->

                    <div class="jp-progress">
                        <div class="jp-seek-bar">
                            <div class="jp-play-bar"></div>
                        </div>
                    </div>
                    <div class="jp-volume-bar">
                        <div class="jp-volume-bar-value"></div>
                    </div>
                    <div class="jp-current-time"></div>
                    <div class="jp-duration"></div>                   
                </div>

                <div class="jp-no-solution">
                    <span>Update Required</span>
                    To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
                </div>
            </div>
        </div>
    </body>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">

<head>
<?php } ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:41:01+00:00Added an answer on June 4, 2026 at 3:41 am

    so you have a few issues here. most of them are in js. Also i looked at the jplayer api and it seems that it can only play one song at a time, which is why you have that loop in there i suppose.

    Here are your issues:

    • Ideally you want to have one document ready function in jquery. This makes your code less all over the place. I would make one function if you can help it which in this case you can.
    • in your code, the selector $(".jquery_jplayer_1") will return a jquery object containing 2 elements (since you have 2 divs of that class on the page after the loop), but since you have 2 functions initing the jplayer to those 2 elements (first with mp3#1 then mp3#2) you will either break jplayer on 2nd init or set them both to be mp3#2
    • you have a trailing comma in your setMedia object: mp3: "<?=$row->songURI?>", – this will break older IE with a very cryptic js error. remove trailing commas.
    • you have 2 class attributes on the empty jplayer div!

    the proper way to do this would be to:

    • move the loop to be around the 2 jplayer divs, the container and the empty player div
    • in the loop make sure to output the classes as jquery_jplayer_1 and jquery_jplayer_2 and same for the containers
    • put a 2nd loop inside the ready function to output separate init calls to jplayer. here is what the 2nd loop iteration output should look like:

             $(".jquery_jplayer_2").jPlayer({
                  ready: function(event) {
                      $(this).jPlayer("setMedia", {
                          mp3: "<?=$row->songURI?>"
                      });
                  },
                  cssSelectorAncestor: '.jp_container_2',
                  swfPath: "http://www.jplayer.org/2.1.0/js",
                  supplied: "mp3"
              }); 
      

    note that i added cssSelectorAncestor: ‘.jp_container_2’ you will need to have that in your init functions to tell it which container to use. each player should have a seperate container.

    i hope this helps

    also, you have some extra doc type crap at the bottom.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I need to clean up various Word 'smart' characters in user input, including but
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.