Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/03/2009, 10:16
majony
(Desactivado)
 
Fecha de Ingreso: diciembre-2008
Mensajes: 421
Antigüedad: 15 años, 4 meses
Puntos: 0
Problemas con el MVC

Hola amigos tengo mi gestor de noticias y mi listado es de forma general ahora encontre un script adecuado es este
Código php:
Ver original
  1. <?php   include ("lib/fecha.php"); ?>
  2. <BODY>
  3.  
  4. <H1>Consulta de noticias</H1>
  5.  
  6. <FORM NAME="selecciona" ACTION="consulta_noticias3.php" METHOD="POST">
  7. <P>Mostrar noticias de la categoría:
  8. <SELECT NAME="categoria">
  9.    <OPTION VALUE="Todas" SELECTED>Todas
  10.    <OPTION VALUE="Promociones">Promociones
  11.    <OPTION VALUE="Ofertas">Ofertas
  12.    <OPTION VALUE="Costas">Costas
  13. </SELECT>
  14. <INPUT TYPE="submit" NAME="actualizar" VALUE="Actualizar"></P>
  15. </FORM>
  16.  
  17. <?PHP
  18.  
  19.    // Conectar con el servidor de base de datos
  20.       $conexion = mysql_connect ("localhost", "root", "")
  21.          or die ("No se puede conectar con el servidor");
  22.  
  23.    // Seleccionar base de datos
  24.       mysql_select_db ("lindavista")
  25.          or die ("No se puede seleccionar la base de datos");
  26.  
  27.    // Enviar consulta
  28.       $instruccion = "select * from noticias";
  29.  
  30.       $actualizar = $_REQUEST['actualizar'];
  31.       $categoria = $_REQUEST['categoria'];
  32.       if (isset($actualizar) && $categoria != "Todas")
  33.      
  34.        $instruccion = $instruccion . " where categoria='$categoria'";
  35.  
  36.       $instruccion = $instruccion . " order by fecha desc";
  37.       $consulta = mysql_query ($instruccion, $conexion)
  38.          or die ("Fallo en la consulta");
  39.  
  40.    // Mostrar resultados de la consulta
  41.       $nfilas = mysql_num_rows ($consulta);
  42.       if ($nfilas > 0)
  43.       {
  44.          print ("<TABLE>\n");
  45.          print ("<TR>\n");
  46.          print ("<TH>Título</TH>\n");
  47.          print ("<TH>Texto</TH>\n");
  48.          print ("<TH>Categoría</TH>\n");
  49.          print ("<TH>Fecha</TH>\n");
  50.          print ("<TH>Imagen</TH>\n");
  51.          print ("</TR>\n");
  52.  
  53.          for ($i=0; $i<$nfilas; $i++)
  54.          {
  55.             $resultado = mysql_fetch_array ($consulta);
  56.             print ("<TR>\n");
  57.             print ("<TD>" . $resultado['titulo'] . "</TD>\n");
  58.             print ("<TD>" . $resultado['texto'] . "</TD>\n");
  59.             print ("<TD>" . $resultado['categoria'] . "</TD>\n");
  60.             print ("<TD>" . date2string($resultado['fecha']) . "</TD>\n");
  61.  
  62.             if ($resultado['imagen'] != "")
  63.                print ("<TD><A TARGET='_blank' HREF='img/" . $resultado['imagen'] .
  64.                       "'><IMG BORDER='0' SRC='img/ico-fichero.gif' ALT='Imagen asociada'></A></TD>\n");
  65.             else
  66.                print ("<TD>&nbsp;</TD>\n");
  67.  
  68.             print ("</TR>\n");
  69.          }
  70.  
  71.          print ("</TABLE>\n");
  72.       }
  73.       else
  74.          print ("No hay noticias disponibles");
  75.  
  76. // Cerrar conexión
  77.    mysql_close ($conexion);
  78.  
  79. ?>
  80.  
  81. </BODY>
  82. </HTML>

Bien como estoy tratando de entender bien el MVC estoy haciendo lo mismo pero con el MVC ahora hice esto.
Código php:
Ver original
  1. <table align="center" width="500">
  2.     <form name="buscar" action="index.php?mod=noticias&pag=listado_noticia&id=<?php echo $_GET['id']?>" method="post">
  3.  
  4.     <tr><td colspan="2"> Mostrar las noticias por Categorias </td></tr>
  5.     <tr>
  6.     <td width="87"> Categoria </td>
  7.     <td width="401">  
  8.     <select name="categoria"> <option value=""> Escoger Lista </option>
  9.     <?php
  10.                if ($items_categoria) {
  11.                foreach ($items_categoria as $item_categoria){
  12.                echo "<option value='$item_categoria->id'>$item_categoria->categoria </option>";
  13.                      }
  14.                }
  15.              
  16.               ?>
  17.    
  18.     </select>
  19.     <input name="actualizar" type="submit"  value="actualizar"/>
  20.     </td>
  21.     </tr>
  22.     </form>
  23.     </table>
  24.    <table border="0" cellspacing="0" cellpadding="0" width="500" align="center">
  25.      
  26.         <tr>
  27.           <td class="bodyText">
  28.             <table width="500" border="1">
  29.               <tr>
  30.                
  31.                 <td>ID</td>
  32.                 <td>Titulo</td>
  33.                 <td>Texto Corto</td>
  34.                 <td>Fecha de publicacion </td>
  35.                 <td>Publicado</td>
  36.                 <td colspan="3" align="center">Opciones</td>
  37.               </tr>
  38.               <?php
  39.                 foreach ($items_noticia as $item_noticia) {
  40.               ?>
  41.               <tr>
  42.                 <td><?php echo $item_noticia->id ?></td>
  43.                 <td><?php echo $item_noticia->titulo ?></td>
  44.                 <td><?php echo $item_noticia->texto_corto ?></td>
  45.                 <td><?php echo $item_noticia->fecha_publicacion ?></td>
  46.                 <td><?php if($item_noticia->estado == 1) echo "Si"; else echo "No"; ?></td>
  47.                 <td><a href="index.php?mod=noticias&pag=editar_noticia&id=<?php echo $item_noticia->id; ?>">Modificar</a></td>
  48.                 <td><a href="index.php?mod=noticias&pag=eliminar_noticia&id=<?php echo $item_noticia->id; ?>">Eliminar</a></td>
  49.                 <td><a href="index.php?mod=noticias&pag=leer_noticia&id=<?php echo $item_noticia->id; ?> ">Leer mas..</a></td>
  50.                
  51.                  </tr>
  52.               <?php
  53.                 }
  54.               ?>
  55.               <tr>
  56.                 <td colspan="9">Nro de Resultados: <?php echo count($items_noticia); ?></td>
  57.               </tr>
  58.             </table>
  59.             <a href="index.php?mod=noticias&pag=insertar_noticia&id=<?php echo $_GET['id']?>">Registar nueva noticia</a>
  60.             </td>
  61.   <tr>
  62. </table>
Y este es mi controlador
Código php:
Ver original
  1. case 'listado_noticia':
  2.         default:
  3.         //if(!empty($_SESSION['usuario_id'])&&($_SESSION['usuario_nivel']==3)){
  4.            //$actualizar = $_POST['actualizar'];
  5.            $categoria = trim ($_POST['categoria']);
  6.            
  7.            $id = intval($_GET['id']);
  8.             //if ($MOD['categorias']->isCategoria($id)) {
  9.                 $items_categoria = $MOD['categorias']->getCategorias();
  10.                
  11.                 $items_noticia = $MOD['noticias']->getNoticias($id);
  12.                
  13.                 if ($items_noticia) {
  14.                     include('modulos/noticias/vistas/listar_noticia.html.php');
  15.                 } else {
  16.                     echo 'No existen noticias publicadas';
  17.                 }

El problema que tengo es que al momento de hacer click en actualizar no me funciona no existe accion