Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

duda con menus en DB

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Spanish
View previous topic :: View next topic  
Author Message
kenmasters
Smarty n00b


Joined: 11 Feb 2008
Posts: 3

PostPosted: Mon Feb 11, 2008 6:09 am    Post subject: duda con menus en DB Reply with quote

Tengo una duda, digamos que deseo almacenar todo el varios bloques de menu dentro de una misma tabla en una base de datos de la siguiente manera por ejemplo:

TABLA : Menus, los campos son MENU, NOMBRE, URL y VISIBLE

MENU | NOMBRE | URL | VISIBLE
inicio home index.php si
inicio descargas descargas.php si
inicio noticias noti.php si
inicio donde donde.php si
menu2 porque pq.php si
menu2 quefue2 pq1.php si
menu2 adonde2 pq2.php si
menu2 nose3 pq3.php si



cuando haga una query a la base de datos seleccionar todo y usando el smarty ya sea con el foreach y con section leer los bloques de esa tabla de la siguiente manera, por ejemplo ( sin tener en cuando la cantidad de menus que sean..):


inicio
- home
- descarga
- noticias
- donde

menu2
- que fue
- a donde
- ... etc..
Back to top
View user's profile Send private message
kenmasters
Smarty n00b


Joined: 11 Feb 2008
Posts: 3

PostPosted: Thu Feb 21, 2008 3:37 am    Post subject: Solucion Reply with quote

PHP

Code:

$tmp = mysql_query("SELECT * FROM Menus ORDER BY MENU");
while($row = mysql_fetch_array($tmp, MYSQL_ASSOC))
{
  $menus[] = $row;
}
$smarty->assign('menus', $menus);


Template

Code:

{assign var=lastmenu value=" "}
{foreach item=thismenu from=$menus}
  {if $lastmenu ne $thismenu.MENU}
     <br>{$thismenu.MENU}<br>
     {assign var=lastmenu value=$thismenu.MENU}
  {/if}
   - {$thismenu.NAME}<br>
{/foreach}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Spanish All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP