Welcome Guest, Not a member yet? Register   Sign In
iframe in view php
#1

[eluser]jupiter1031[/eluser]
I have a module in the view folder that basically is the container for an iframe. The Iframe module will display data from the database.
My first problem is how to correctly use 'src="something.php"' within the iframe statement. 'something.php' is also in the view folder. I need to pass the database information to that module.
The website is a rework of www.greiner-engineering.com select projects from the navbar. All the project information will be in a database and the screen needs to scroll.
Any suggestion is appriciated.
#2

[eluser]Twisted1919[/eluser]
[quote author="jupiter1031" date="1297834866"]
My first problem is how to correctly use 'src="something.php"' within the iframe statement. 'something.php' is also in the view folder. I need to pass the database information to that module.[/quote]
For "something.php" you will create a class method named something and you will do all the logic there (including the loading of view files) then simple, reference it in the src attribute like:
src="<?php echo site_url('my_controller/something');?>"
and it will load your custom method .

DO NOT refrence the view file directly, like http://www.mydomain.com/application/views/something.php because you will be in big troubles, just learn how it needs to be done in CI way.
#3

[eluser]Basketcasesoftware[/eluser]
Seems to work pretty good for me. I like! Good gallery. :coolsmile:
#4

[eluser]jupiter1031[/eluser]
Thank you for your help. As you see at the example below I have created a method put_project. In eng-projects.php I successfully implemented the iframe like this

Code:
<iframe id="dsp_projects" src="<?php echo site_url('project/put_project');?>" frameborder=0 scrolling=auto height=720 width=900>></iframe>
As you can see I am passing $data successfully to eng-projects.php. How do I get $data into eng-project-table.php?

These are the controller methods of class Project:

Code:
function get_year_query()
    {
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
        $this->form_validation->set_rules('year_from', 'Year From', 'required|exact_length[4]|numeric');
        $this->form_validation->set_rules('year_to', 'Year To', 'required|exact_length[4]|numeric');

        if ($this->form_validation->run() == FALSE)
        {

            $this->load->view('get_years_view');
        }
        else
        {
            $this->load->model('projects_model');
            $data['records'] = $this->projects_model->getProjectYears();
            $this->load->view('eng-projects',$data);

        }
    }
    function put_project()
        {$this->load->view('eng-project-table',$data);} //this does not work. $data does not get passed to this method!!!
#5

[eluser]Twisted1919[/eluser]
put_project() is a new request that doesn't have anything to do with get_year_query() therefore you need to query the database again and populate $data once again, then pass it .
#6

[eluser]jupiter1031[/eluser]
Thank you for your help! Very much appreciated!




Theme © iAndrew 2016 - Forum software by © MyBB