loops

PHP Looping based on date

ok so i have this array of about 151 elements and there is a date field as one of the elements. The array is a two week range. I want to count how many elements are in the first week and how any are in the second week. Here is my example array. [0] => Array ( [0] => 4d50 [date] => 07-10-2010 [telephone] => so...

Image change every 30 seconds - loop

Hey I would like to make an image change after 30 seconds... The code I'm using looks like this: Script: var images = new Array() images[0] = "image1.jpg"; images[1] = "image2.jpg"; images[2] = "image3.jpg"; setTimeout("changeImage()", 30000); var x=0; function changeImage() { document.getElementById("img").src=images[x] x++; } An...

php loops and grouping mysql

Hi There, I am currently adding a purchase history section to payment system, the system is built in PHP (codeigniter framework) and mysql. The idea of the payment history section is that all the customer purchases are grouped together by date, so in the end the HTML would look similar to this, My question is I can get the data out o...

Loop to create multiple div elements? JQUERY

Any idea what's wrong with my code? var pageLimit=30; $(document).ready(function() { for(var i = 1; i <= pageLimit; i++) { $('#test').append('<div id="page' + i + '" class="touch">TESTING</ div>' ) } } What I want is to have that function create as many divs in the body as the pageLimit value. So if someone were to go into the co...

creating a bash script - loop through files

I was wondering, I need to run indent with a bunch of parameters as: indent slithy_toves.c -cp33 -di16 -fc1 -fca -hnl -i4 -o slithy_toves.c What I want is to read each *.c and *.h files and overwrite them with the same name. How could I do this in a bash script, so next time I can run the script and do all the indentation at once? ...

loop until all elements have been accessed N times in python

I have a group of buckets, each with a certain number of items in them. I want to make combinations with one item from each bucket. The loop should keep making different combinations until each item has participated in at least some defined number. I can easily see how to run the loop and stop once a single element has been accessed a c...

Cakephp looping through database saves, for some reason it only saves on the last instance of loop?

I'm trying to get this loop to save a new record to the database in cakephp on each iteration but for some reason its only saving it on the last one (so in this case it saves a record called "test9" but no others.. this type of save has worked for me so far in cakephp and I am completely stumped by this, I would appreciate any advice Th...

Javascript closures - variable scope question

I'm reading the Mozilla developer's site on closures, and I noticed in their example for common mistakes, they had this code: <p id="help">Helpful notes will appear here</p> <p>E-mail: <input type="text" id="email" name="email"></p> <p>Name: <input type="text" id="name" name="name"></p> <p>Age: <input type="text" id="age" name="ag...

How can I make a function that repeats itself until it finds ALL the information?

I want to create a PHP function that goes through a website's homepage, finds all the links in the homepage, goes through the links that it finds and keeps going until all the links on said website are final. I really need to build something like this so I can spider my network of sites and supply a "one stop" for searching. Here's what...

How to repeat or loop this queue on jQuery?

Hi, This is code for a faded slideshow. Is there a way to repeat or loop this queue? To start again on this top code $("#page2_image").hide(); Here's the code in jQuery: $(document).ready(function(){ $("#page2_image").hide(); $("#page3_image").hide(); $("#page1_image").fadeOut(10000); $("#page2_image").fadeIn(10000).fadeOu...

In a bit of a while loop mess!

Hello all. I have spent quite some time making a function and the last 15-20 minutes trying to figure this out. I need help! I am selecting multiple rows from the database and then running them in a while loop. They are available on a dropdown menu. <form method="POST" action="adminprocess.php"> <fieldset> <p> <label class...

for Loop with if-else statement.

I would like to ask some logic question here. Let say I have a for loop in javascript to remove the whole items:- var i = 0; for (i=0;i<=itemsAll;i++) { removeItem(i); } I do not want to remove item when i = current = e.g. 2 or 3. how do I or where do I add a if-else statement in this current for loop? Please help, anyone? ...

Interrupt/Abort a VBA-Loop

Hi Mates, I have a question on VBA on Excel: Is it (if yes, how) possible, to abort a long term loop? I have a Loop over several thousands of cells, which takes some minutes. How can I do a button or something like this to interrupt this loop manually? Building a button and overlay it with a makro is no problem ;-) Only the thing the m...

how to make oracle for loop fast

Query below takes 20 seconds to run. user_table has 40054 records. other_table has 14000 records select count(a.user_id) from user_table a, other_table b where a.user_id = b.user_id; our restriction is that any query running more than 8 seconds gets killed...>_< I've ran explain plans, asked questions here but based on our restrictio...

Question about nested loops

I am new to programming and having some problem figuring out nested loops. I have a list of data that I want to extract from a larger file. I am able to extract one item of data from the larger file successfully but I need to extract 100 different trials from this larger file of thousands of trials. Each trial is one line of data of the ...

How to increase number of iterations from within the loop in php?

Hi, I'm working on custom pagination system and encountered following problem. When one of the elements is filtered out of the set, the size of the final array is smaller than needed. Therefore I'm looking for a solution to increase the number of iterations from within the loop to always get array consisting of 50 elements. $limit = 50...

Jquery Problem for stopping the loop

Hi guys, I got this jquery code. And this is some kind of slideshow with fading effect. So it loops... this is the first code $(document).ready(function(){ function looptour(){ $("#health").hide(); $("#billing").hide(); $("#pension").delay(6000).fadeOut(2000); $("#health").delay(6000).fadeIn(2000).del...

xslt - get last row from a foreach loop (split into 3 columns)

Hi everyone. I'm looping through 1-20 <li>'s using xslt and I'm trying to figure out how to add a class to the last row of the list, when displayed in a 3 column grid type format. At the moment, I'm using this code to add a class of col-last to every 3rd column in the list. <xsl:if test="not(position() mod 3)"> <xsl:attribute name="...

Checkeach array item has a value

I am trying to error check a form that on submitting creates an array, however no value in that error can be empty, how can I check this using PHP, the array looks like this, Array ( [campaign_title] => [campaign_keyword] => [introduction] => [position] => left [campaign_headline] => Array ( [...

javascript timer or intervals created in loop using closure

I'm using jQuery to setup a timer or interval loop on a few elements to check them every couple seconds. I've tried setting a timer and checking if I should restart it, or setting and interval and checking if I should stop it. Although simplified, this is basically what I need: var mytimers = new Array(); $('div.items').each(function(...