CodeIgniter Forums
url library/anchor function for content on database content - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter Archived (from EllisLab) (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: url library/anchor function for content on database content (/thread-45547.html)



url library/anchor function for content on database content - El Forum - 09-26-2011

[eluser]dwlamb[/eluser]
I have need for an anchor tag embedded within content drawn from the database for the application I am working on. Yet, for some reason CI is not executing the anchor function.

These are relevant sections within my controller for this app
Code:
class Main extends CI_Controller {
function __construct() {
  parent::__construct();

  $this->load->helper('url');
....
}
public function index() {
.....
  $query = "SELECT id, recipe, instruc FROM main WHERE id='".$id."'";
  $recipe=$this->db->query($query)->result_array();
  if ($recipe) {
   $recipe=$recipe[0];
   $data['recipe_title'] = $recipe['recipe'];
   $data['recipe_instruc'] = $recipe['instruc'];
   $data['navigation'] = $this->main_model->buildMenu();
  }
.....

In my View, url helper is also loaded and the value from the $data array echoed with appropriate syntax:
Code:
<?php echo $recipe_instruc?>


The section of text returned from the database is as follows:
Code:
Serve over ice cream or <?php echo anchor('main/index/7', 'profiteroles');?>

The above quoted text is a snippet of the overall block of text returned from the database. All the rest of the text echos properly to the view. The section of text that should echo as a coded anchor tag does not.

I can understand the anchor function not being executed at the Controller level but it should execute at the View level, no?