Ahora mismo supongamos que tengo esto:
Código PHP:
$sql='select * from articulo';
$query=mysql_query($sql);
while($result=mysql_fetch_array($query)){
$ARTICULO_TITULO=$result['articulo_titulo'];
$ARTICULO_TEXTO=$result['articulo_texto'];
$ARTICULO_COMENTARIOS=$result['articulo_comentarios'];
$plantilla_modular='
<table border="1" cellspacing="1" cellpadding="1">
<tr>
<th scope="col">'.$ARTICULO_TITULO.'</th>
<th scope="col">'.$ARTICULO_TEXTO.'</th>
<th scope="col">'.$ARTICULO_COMENTARIOS.'</th>
</tr>
</table>
';
echo $plantilla_modular;
}
Esto funciona corretamente y me muestra todos los articulos en orden.
Ahora mi intención es llevarme la variable plantilla modular a otro archivo llamado por ejemplo plantilla y se quedaria tal que asi:
ARCHIVO DE PROGRAMACION
Código PHP:
$sql='select * from articulo';
$query=mysql_query($sql);
while($result=mysql_fetch_array($query)){
$ARTICULO_TITULO.=$result['articulo_titulo'];
$ARTICULO_TEXTO.=$result['articulo_texto'];
$ARTICULO_COMENTARIOS.=$result['articulo_comentarios'];
require_once("plantilla.php");
echo $plantilla_modular;
}
Código PHP:
<?php
$plantilla_modular.='
<table border="1" cellspacing="1" cellpadding="1">
<tr>
<th scope="col">'.$ARTICULO_TITULO.'</th>
<th scope="col">'.$ARTICULO_TEXTO.'</th>
<th scope="col">'.$ARTICULO_COMENTARIOS.'</th>
</tr>
</table>
';
?>
Con este sistema separo la programación del diseño pero tengo un pequeño problema. Siempre se muestra el mismo artículo. Si tengo 10 artículos, se muestra 10 veces el mismo.
¿Alguien sabe que puedo estar haciendo mal y como puedo solucionarlo?