[eluser]xwero[/eluser]
Quote:More fields to create the table ? You use the fields that needs... no more.
Can you show an sql concat example and explain better ?
Thanks for the replys,
Greetings. !
In your example you use the id but most of times you are not going to create a column for the id field as it is most of the time a metadata field.
Based on your example the concat function would be
Code:
$this->db->select("id h1, field h2, CONCAT('".site_url()."/dir/". url_title($link) ."/',id) h3");
And then to create a link you have to do
Code:
$rows = $query->results_array();
foreach($rows as $key=>$row)
{
$rows[$key]['h3'] = anchor($row['h3'],$row['h2']);
}
Using an alias for a field takes care of the headers and i reuse the array created by the query. Your code adds the link at the end of the row but what if you want it between the first and second column. I only have to move the h3 column where you would have to use functions to remove the last column and slip it in between the columns.
Bottom line it's best to do string manipulations in the sql statements and let php take care of adding the markup.