Welcome Guest, Not a member yet? Register   Sign In
how generate row and celd with html table ?
#1

[eluser]Asinox[/eluser]
Hi, all right here? Smile, i hope Smile

Guys i need to generate 3 columns with 5 row with HTML TABLE and the data from the database...

so,please, how ill generate a table with x rows and x columns?

Thanks Smile
#2

[eluser]CroNiX[/eluser]
Did you read the manual?
#3

[eluser]Colin Williams[/eluser]
http://ellislab.com/codeigniter/user-gui...table.html

If your query returns 5 rows of 3 fields each, then you can pass the result to the HTML Table class, and voila!
#4

[eluser]Asinox[/eluser]
yes, i readed the guide, but, there 's just make_column, but how ill generate just 3 rows , with make_column ill control the columns, but the rows...i just i want to control the rows, if i need to make 10 columns is fine, but 10 columns with just 3 rows... i dont know if im clear Sad

something like that:
Code:
<table>
<tr>
   <td>CELD 1 </td><td>CELD 2 </td><td>CELD 3 </td><td>CELD 4 </td>
</tr>
<tr>
   <td>CELD 1 </td><td>CELD 2 </td><td>CELD 3 </td><td>CELD 4 </td>
</tr>
<tr>
   <td>CELD 1 </td><td>CELD 2 </td><td>CELD 3 </td><td>CELD 4 </td>
</tr>
</table>
PD: sorry with my english
#5

[eluser]CroNiX[/eluser]
Didn't read the guide too closely Smile
Code:
$this->table->add_row('CELD1', 'CELD2', 'CELD3', 'CELD4');
#6

[eluser]Asinox[/eluser]
mmmm well i readed but i see that i not understand Sad
sorry, let me try

Thanks
#7

[eluser]Asinox[/eluser]
ok, i see i understand.... add_row add 1 row... but my data coming from database... maybe im lost, so, how ill show the data in x columns and just 3 rows when my data coming from the database

thanks for u patience
#8

[eluser]CroNiX[/eluser]
something like:
Code:
$query = $this->db->query("YOUR QUERY");

foreach ($query->result_array() as $row)
{
    $this->table->add_row($row['field1'], $row['field2'], $row['field3'], $row['field4']);    
}
#9

[eluser]Colin Williams[/eluser]
Read even closer. Like, the very first part:

Quote:Here is an example of a table created from a database query result. The table class will automatically generate the headings based on the table names (or you can set your own headings using the set_heading() function described in the function reference below).
Code:
$this->load->library('table');

$query = $this->db->query("SELECT * FROM my_table");

echo $this->table->generate($query);
#10

[eluser]CroNiX[/eluser]
Sure, assuming you are only grabbing what you want to output in your table.




Theme © iAndrew 2016 - Forum software by © MyBB