Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    62
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question php javascript continuous loading

    I've built a page that creates an array from php using javascript (this will eventually go into a slideshow script).

    The array displays on the page but the page continues to load - the hourglass doesn't go away.

    Do I need to put a stop somewhere?

    Here's the page:

    Code:
    <?php
    
    // Performing SQL query
    $query = 'SELECT * FROM photographers ORDER BY photo_id LIMIT 10 ';
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    
    //var for hold data javascript array
    $javascriptarray= " <script language=\"javascript\">phpjavasarr = new Array();"."\n";
    
    //we need counter
    $iC=0;
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
    
    $col_value=htmlentities($line["first_name"]);
    /*$col_value=htmlentities("<a href='http://www.google.com'>".$line[first_name]."</a>"]);*/
    $javascriptarray.= "phpjavasarr[$iC]=\"$col_value\";"."\n";
    
    $iC++;
    }
    //end of javscript and simple example show quote
    $javascriptarray.="
    function showquote() {
    var x=0;
    for (x=0; x<$iC; x++)
    {
    document.write(phpjavasarr[x]);
    }
    }
    </script>";
    
    //print it
    echo $javascriptarray;
    ?>
    </head>
    
    <body >
    
    <a href="javascript:showquote()">show names</a>
    </body>

  • #2
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    it's the document.write

    try ending with document.close()


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •