Re: [SMARTY] {section} printing too many rows

From: Date: Fri, 10 Jan 2003 22:22:28 +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-7123@lists.php.net to get a copy of this message
> > 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. I tried both of these methods, and each came up with the same result as before. When I popped of the last value of the array, then the last value was dropped, but I'd still have that extra blank row at the end when smarty printed it out. FYI, I printed out the value of $num_rows and it came back with the correct number of rows (not including this blank row that isn't actually in the array). $result = mysql_query("select * from servers"); $num_rows = mysql_num_rows($result); for($i=0; $i<$num_rows; $i++) { $row = mysql_fetch_array($result); Any other ideas as to what might be going on? I'm stuck. Justin

« previous php.smarty.general (#7123) next »