EllisLab text mark
Advanced Search
     
Repeat 12 times the values that I show in a table.
Posted: 16 November 2012 09:54 AM   [ Ignore ]
Joined: 2012-10-12
57 posts

I m generating one dynamic table with info from a DB, all goes perfect. But the problem is that if my table of DB has 20 records. When I generate the table it show many records. generally 6 to 12 times my real info..

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start(); //we need to call PHP's session object to access it through CI
class MaincontentFunction extends CI_Controller 
{
 
public function __construct()
 
{
  parent
::__construct();  
  
$this->load->model('content',''TRUE);
 
}
 
function index()
 
{
  $content 
"";
  
$query $this->content->contenido();
  
$content.="
  [removed][removed]
  <table cellpadding='0' cellspacing='0' border='0' class='display' id='tableMainContent'>
    <thead>
                    <tr>
                        <th>Id</th>
                        <th>Nombre</th>
      <th>Propietario</th>
      <th>Ultima modificacion</th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>
                    </tr>
                </tfoot>
                  <tbody>
  "
;

  foreach(
$query->result() as $row)
  
{
   $data 
= array(
   
'idfuncion' => $row->idfuncion,
   
'descripcioncorta' => $row->descripcionCorta,
   
'creadopor' => $row->creadopor,
   
'fechacreacion' => $row->fechacreacion,
   );
   
$content.="
   <tr>
    <td><input name='opcion-res' type='radio' align='center'/></td>
    <td><a>
$data[descripcioncorta]</a></td>
    <td>
$data[creadopor]</td>
    <td>
$data[fechacreacion]</td>
   </tr>
   "
;   
  
}
  $this
->output->set_output($content); 

Basically this is the controller that allow me generate the dynamic table, I know that I’m not following exactly the MVC model But Right now I need it like this.

Please I need help..

This is basically for may to do a manager of downloads, If someone has a better Idea please let me know.
Many tahnks

 
Posted: 16 November 2012 08:17 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-28
2435 posts

It’s likely an issue with your database query. Your controller looks fine; your foreach() loop won’t duplicate results like that.

You forgot to close your table’s HTML, by the way.