cambiar codigo codeigniter
Publicado por lorena (8 intervenciones) el 23/02/2015 17:43:59
Buenas tardes a todos;
tengo un histórico de noticias creado pero lo estoy intentando pasar a codeigniter y no hay forma, me podriais ayudar que me estoy volviendo loca. Gracias
Codeigniter modelo
tengo un histórico de noticias creado pero lo estoy intentando pasar a codeigniter y no hay forma, me podriais ayudar que me estoy volviendo loca. Gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php require_once('conexiones/conexionblog.php'); ?>
<?php
$query_DatosMuro = "SELECT fchFecha, idNoticia, strTitulo FROM `tblnoticias` ORDER BY fchFecha DESC";
$DatosMuro = mysqli_query($conexionblog, $query_DatosMuro) or die(mysqli_error());
$totalRows_DatosMuro = mysqli_num_rows($DatosMuro);
$nav = array();
while ( ($fila = mysqli_fetch_array($DatosMuro)) > 0 ){
foreach($fila as $news){
$year = date(fechaporyear($fila['fchFecha']));
$month = fechapormes($fila['fchFecha']);
$nav[$year][$month][$fila['idNoticia']] = $fila['strTitulo'];
}
}
///
<section class="hemeroteca">
<hgroup><h1 class="title">Hemeroteca</h1></hgroup>
<ul>
<?php
foreach ($nav as $k => $v) {
?>
<li class="primero"><?php echo $k ?>
<ul>
<?php
foreach ($v as $k2 => $v2) {
?>
<li><?php echo $k2.' ('.sizeof($v2).')' ?>
<ul>
<?php
foreach ($v2 as $k3 => $v3) {
?>
<li><a href="noticias_anteriores.php?ID=<?php echo $k3 ?>"><?php echo $v3 ?></a></li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
</ul>
Codeigniter modelo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php //
class Hemeroteca_model extends CI_Model {
public function __construct() {
parent::__construct();
}
function lista_noticias($idNoticia) {
$this->db->select('idNoticia',$idNoticia,'fchFecha','strTitulo','url_Noticia');
$this->db->group_by(Month('fchFecha'), Year('fchFecha'));
$consulta = $this->db->get('tblnoticias');
while($q->result() > 1)
{
foreach($consulta as $row)
$year = date(fechaporyear($row['fchFecha']));
$month = fechapormes($row['fchFecha']);
$nav[$year][$month][$row['idNoticia']] = $row['strTitulo']; // add each user id to the array
}
}
}
Valora esta pregunta


0