0
ich eine Controller-Klasse wie hiereine Funktion in einer Controller-Klasse aufrufen
gezeigt<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Results extends CI_Controller
{
public function index()
{
$this->load->model('my_model');
}
function validate()
{
//set validation rules here
//validate form input
if ($this->form_validation->run() == FALSE) {
// fails
$this->load->view('get_results');
}
}
function ranking1(){
$data['returned_records']= $this->my_model- >get_ranking();
$html=$this->load->view('view_ranking', $data, true);
$pdfFilePath = "ranking.pdf";
$this->load->library('m_pdf');
//generate the PDF from the given html
$this->m_pdf->pdf->WriteHTML($html);
//download it.
$this->m_pdf->pdf->Output($pdfFilePath, "D");
}
function top5(){
$data['returned_records']= $this->school_model->get_top5();
$html=$this->load->view('view_top5', $data, true);
//this the the PDF filename that user will get to download
$pdfFilePath = "top5.pdf";
//load mPDF library
$this->load->library('m_pdf');
//generate the PDF from the given html
$this->m_pdf->pdf->WriteHTML($html);
//download it.
$this->m_pdf->pdf->Output($pdfFilePath, "D");
}
}
ich diese Funktionen aus meiner Sicht so nennen wollen:
<a href="<?php echo base_url(); ?>results/top5">Top 5</a><br>
<a href="<?php echo base_url(); ?>results/ranking1">ranking</a><br>
wenn nenne ich die Funktionen in der Controller innerhalb der index() Methode funktionieren sie gut, aber sie in einem anrufen ein Tag wie oben gezeigt funktioniert.