FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » problem with arrays/loops in PHP and javascript
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
problem with arrays/loops in PHP and javascript [message #34544] Mon, 06 November 2006 14:37 Go to next message
jfern is currently offline  jfern   United States
Messages: 2
Registered: November 2006
Location: New York
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
I am having a problem where my code only works if I fill 14 or less elements of an array(using php and javascript. If I use more than that, it doesnt work:


var a = new Array();
var i = 0;

<?php
$k = 15;
for ($j = 0; $j < $k ; $j++)
{
?>
a[i] = ('<?php echo $rows[$j] ?>');
i++;
<?php
}
?>

when $k is 14 or less, this code works fine, but when it is 15 or more, it doesnt work. I can't for the life of me figure out why this would be a problem.

Any help would be greatly appreciated.
Thanks!
-Josh
icon1.gif  Re: problem with arrays/loops in PHP and javascript [message #36383 is a reply to message #34544] Tue, 20 March 2007 15:29 Go to previous message
nikola99 is currently offline  nikola99   United States
Messages: 3
Registered: March 2007
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Try removing the parentheses in JavaScript array assignments.

Also this might be quicker.

<?php
$rows = implode("', '", $rows);
?>
<script>
var a = new Array('<?=$rows?>');
</script>

Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: PHP & MYSQL OVERHEAD / INTERUPTION PROBLEM
Next Topic: Attaching File To a Page
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Oct 18 01:50:59 EDT 2017

Total time taken to generate the page: 0.00594 seconds