RE: [SMARTY] {section} printing too many rows
| From: | Rod Kreisler | Date: | Fri, 10 Jan 2003 13:20:04 +0000 |
| Subject: | RE: [SMARTY] {section} printing too many rows | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7114@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Justin Mitchell [mailto:lists@justinmitchell.net]
> Sent: Friday, January 10, 2003 5:42 AM
> To: smarty-general@lists.php.net
> Subject: [SMARTY] {section} printing too many rows
>
>
> Howdy. I'm having trouble with {section} printing one extra row
> than it's supposed to. Being that I've pulled another
> all-nighter, I wouldn't be surprised if it's a user error, but
> would someone take a quick look at the code to see what's going
> on? I'm stumped.
>
> index.php:
> // include stuff, define functions, connect to database removed
>
> $result = mysql_query("select * from servers");
> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
> $i=$row[id]-1;
>
I've found that this happens when using a while loop with the mysql_fetch_*
functions. Either pop off the last member of the array after the while loop
or use mysql_num_rows and a for loop.