Welcome Guest, Not a member yet? Register   Sign In
Repeat 12 times the values that I show in a table.
#1

[eluser]masentinel900[/eluser]
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..

Code:
<?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>&lt;input name='opcion-res' type='radio' align='center'/&gt;&lt;/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
#2

[eluser]Aken[/eluser]
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.




Theme © iAndrew 2016 - Forum software by © MyBB