Smarty + Arrays print problem
| From: | Pablo Fischer | Date: | Sat, 05 Apr 2003 23:31:10 +0000 |
| Subject: | Smarty + Arrays print problem | ||
| References: | 1 2 3 4 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9136@lists.php.net to get a copy of this message | ||
Hello All!
Im using MySql and Im using two queries:
Query #1: Get what blocks are available
Query #2: Contains the data of each block available
Each Query get data from different Tables.
The problem: In the browser I can only see ONE data of each block. For example, In block 1 I have 3
links, and I just get printed 1 link.
Im using the following php-function and tpl files.
I dont know why just one link its being printed.
Thanks for all.
Pd. Sorry for my code, its in spanish. but its very clearly. Any question, just send an email :-)
function buscar_bloques_izq() {
global $conexion, $Template;
$sql_b = "SELECT * FROM Bloques WHERE status_bloque='1' AND
alineacion_bloque='izq' ORDER BY posicion_bloque ASC";
$query_b = mysql_query($sql_b, $conexion);
$ndatos_b = mysql_num_rows($query_b);
$Bloque = array();
$BloqueContenido = array();
for($i=0; $i<$ndatos_b; $i++) {
$row_b = mysql_fetch_array($query_b);
$Bloque[] = array("titulo" => $row_b["nombre_bloque"],
"tipo" => $row_b["tipo_bloque"]);
$sql_bc = "SELECT * FROM BloqueContenido WHERE
referencia_bloquec='".$row_b["id_bloque"]."' ORDER BY id_bloquec
ASC";
$query_bc = mysql_query($sql_bc, $conexion);
$ndatos_bc = mysql_num_rows($query_bc);
for($j=0; $j<$ndatos_bc; $j++) {
$row_bc = mysql_fetch_array($query_bc);
$BloqueContenido[$i][] = array("texto" => $row_bc["nombreurl_bloquec"],
"url" => $row_bc["url_bloquec"]);
}
echo "<b>$ndatos_bc</b>";
}
$Template->assign(array("bloque_izq" => $Bloque,
"bcontenido_izq" => $BloqueContenido));
}
And the tpl file:
{section name=i loop=$bloque_izq}
....(html code)
{if ($bloque_izq[i].tipo == "textdin")}
{section name=b loop=$bcontenido_izq}
<li><a
href='{$bcontenido_izq[i][b].url}'>{$bcontenido_izq[i][b].texto}</a>
{/section}
{elseif ($bloque_izq[i].tipo == "imgdin")}
{section name=b loop=$bcontenido_izq}
<a href='{$bcontenido_izq[i][b].url}'><img
src='{$bcontenido_izq[i][b].texto}'></a><br>
{/section}
{/if}
..../html code)
{/section}
--
Pablo Fischer <exilion@yifan.net>