Re: Problem with inserting numbers...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11 Aug 2011 at 02:22, Jason Pruim <pruimj@xxxxxxxxx> wrote: 

> while ($num != "10000") {
>    while($row = mysql_fetch_assoc($result)) {
>        $padnum = number_pad($num, "4");
>        echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "<BR>";
>        $num++;
>    }
>
>
> }

This is certain to fail. You've got the $num++ in the *inner* loop, and are checking its value in the *outer* loop. Think about it: suppose you enter the inner loop with $num being 9998. Suppose also that you then go round the inner loop 5 times. What is the value of $num when you then exit the inner loop in order to do the test against 10000 in the outer loop?

You need to rework that logic.

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux