Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/11/2011, 15:26
Avatar de vicion
vicion
 
Fecha de Ingreso: noviembre-2011
Mensajes: 79
Antigüedad: 12 años, 5 meses
Puntos: 1
Respuesta: Sistema de noticias

Este es mi lista de noticias:

Código PHP:
Ver original
  1. <?php
  2. // verificamos si se ha enviado
  3. // alguna variable via GET
  4. if(isset($_GET['id']) && $_GET['categoria']){
  5. // asignamos los valores
  6. // a las variables que usaremos
  7. $cat_ID = $_GET['id'];
  8. $categoria = $_GET['categoria'];
  9. $clausula = "WHERE notCategoriaID = '$cat_ID'";
  10. // tambien armamos el titular de la pagina
  11. $titulo = "Noticias en la categoria $categoria";
  12. }else{
  13. // de lo contrario
  14. // el titulo sera general
  15. $titulo = "Todas las noticias";
  16. }
  17. // armamos la consulta
  18. $sqlQueryNot = mysql_query("SELECT notTitulo, notTexto FROM sn_noticias
  19. $clausula", $db_link)
  20. echo "<h1>$titulo</h1>";
  21. // mostramos las noticias,
  22. // otra vez usando un bucle while
  23. while($rowNot = mysql_fetch_array($sqlQueryNot)){
  24. echo "<p>------------------------------------------------------</p>";
  25. echo "<h1>$rowNot[notTitulo]</h1>";
  26. echo nl2br($rowNot['notTexto']);
  27.  
  28. }
  29. ?>