{section} printing too many rows
| From: | Justin Mitchell | Date: | Fri, 10 Jan 2003 10:41:37 +0000 |
| Subject: | {section} printing too many rows | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-7109@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;
$fp = fsockopen("udp://$row[ip]", $row[port], $errno, $errstr);
if (!$fp) die("ERROR: $errno - $errstr");
// INFO
hlsend($fp, "info");
fread($fp, 1);
$hl[$i]["name"] = getnull($fp);
$hl[$i]["map"] = getnull($fp);
$hl[$i]["current_players"] = ord(fread($fp, 1));
$hl[$i]["max_players"] = ord(fread($fp, 1));
$hl[$i][ip] = $row[ip].":".$row[port];
fclose($fp);
}
$smarty = new Smarty;
$smarty->assign("server",$hl);
$smarty->display('index.tpl');
====================
index.tpl:
<table>
{section name=i loop=$server}
<tr>
<td>{$server[i].name}</td>
<td>{$server[i].ip}</td>
<td>{$server[i].map}</td>
<td>{$server[i].current_players}/{$server[i].max_players}</td>
</tr>
{/section}
</table>
Thanks!!!
Justin