Re: Problem with inserting numbers...
| From: | Tim Streater | Date: | Thu, 11 Aug 2011 09:22:00 +0000 |
| Subject: | Re: Problem with inserting numbers... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-314487@lists.php.net to get a copy of this message | ||
On 11 Aug 2011 at 02:22, Jason Pruim <pruimj@gmail.com> 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