⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

how to load my own $row with $output



angga777

angga777
  • profile picture
  • Member

Posted 17 October 2012 - 17:39 PM

I have a query:

Example:


$this->db->where('island.id_island',$this->uri->segment(3));
$data['query']=$this->db->get('island');


view:

<?php foreach($query->result()as $row): ?>
<?=$row->island_name?>
<?php endforeach; ?>


I want to display it with $output view. how to render it?

victor

victor
  • profile picture
  • Member

Posted 17 October 2012 - 17:57 PM


...
//controller
$output = $crud->render();
$this->data['crud'] =(array)$output;

$this->data['category'] = //get categories........;
$this->load->view('your_template',$this->data);

....

// veiw
........
<div>
<?=$crud['output']; ?>
</div>
<div>
<div>
<?if($category):foreach($category as $item):?>
<?=$itemp['title']?>
<?endforeach; endif;?>
</div>

angga777

angga777
  • profile picture
  • Member

Posted 24 October 2012 - 08:56 AM

still doesn't work, pal..

js_file, css_file and my query Undefined

victor

victor
  • profile picture
  • Member

Posted 25 October 2012 - 10:37 AM

show,please, controller's code and view

David Leiva

David Leiva
  • profile picture
  • Member

Posted 26 October 2012 - 16:29 PM

I think you are not using grocery crud properly. Look at the examples how it works.

You should do:

[php]
// in your controller
$crud = new grocery_CRUD();
$crud->set_table('island');
$crud->where('island.id_island',$this->uri->segment(3));
$crud->colums('island_name')
$output = $crud->render()

//in your view
echo $output;
[/php]

angga777

angga777
  • profile picture
  • Member

Posted 01 November 2012 - 03:11 AM

My controller

function multiupload()
{
$this->load->library('Image_CRUD');
$image_crud = new Image_CRUD();

$image_crud->set_table('images');

$image_crud->set_primary_key_field('id');
$image_crud->set_url_field('url');
$image_crud->set_title_field('title');

$image_crud->set_relation_field('id_island')
->set_ordering_field('priority')
->set_image_path('assets/uploads/img');

echo '<h2>Upload Photo</h2>';

$output = $image_crud->render();

$this->_upload_output($output);
}

function _upload_output($output = null)
{

$this->data['crud'] =(array)$output;


$this->db->where('island.id_island',$this->uri->segment(3));

$this->data['category'] = $this->db->get('island');
$this->load->view('upload_view.php',$this->data);

}


My View


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />

<?php
foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>

<?php foreach($js_files as $file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>

</head>
<body>

<a href='<?php echo site_url('main_adm/island_management')?>'><b> <<-- back </b></a>
<br><br>
<?if($category):foreach($category as $item):?>
<?=$itemp['island_name']?>
<?endforeach; endif;?>

<div>

<?=$crud['output']; ?>


</div>

</body>
</html>




where is my mistake? can you help vict?