Re: Counting numbers on while..
| From: | Devraj Mukherjee | Date: | Mon, 28 Mar 2005 08:50:44 +0000 |
| Subject: | Re: Counting numbers on while.. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-211690@lists.php.net to get a copy of this message | ||
You basically dont need the for loop all you have to do is increment the value of the variable by one each time in the while loop
Devraj
Louie Miranda wrote:
Hi, im trying to create a number loop on a table where the data came in a database. I have tried the for "loop" and counted $countCards_result from the table where im going to get all the data. ## code ## while ($profile->fetchInto($row)) { for ($i = 1; $i <= $countCards_result; $i++) { $num = $i; print(" <tr> <td>$num</td> <td>" .$row[2]. "</td> </tr> "); } // end of for loop } // end of while ## code ## Well, it did loop the numbers from what did came out of $countCards_result but, the results are wrong because it loops each row from 1 to 10. Here's the example:-- Devraj Mukherjee (devraj@eternitytechnologies.com) Eternity Technologies Pty. Ltd. ACN 107 600 975 P O Box 5949 Wagga Wagga NSW 2650 Australia Voice: +61-2-69717131 / Fax: +61-2-69251039 http://www.eternitytechnologies.com/1 louie edit | delete 2 louie edit | delete 3 louie edit | delete 4 louie edit | delete 5 louie edit | delete 6 louie edit | delete 7 louie edit | delete 8 louie edit | delete 9 louie edit | delete 10 louie edit | delete 1 miranda edit | delete 2 miranda edit | delete 3 miranda edit | delete 4 miranda edit | delete 5 miranda edit | delete 6 miranda edit | delete 7 miranda edit | delete 8 miranda edit | delete 9 miranda edit | delete 10 miranda edit | deleteAnd so on.. What i wanted it to do was..1 louie edit | delete 2 miranda edit | deleteAnd so on.. I was wondering how can i get it to count only the rows, and dont repeat from 1 to 10 on all rows. Please help! -- Louie Miranda http://www.axishift.com