Welcome Guest, Not a member yet? Register   Sign In
small blog help needed passing data
#8

[eluser]echo sara[/eluser]
Thank you!!! for your reply and advice. So i created another function just to return the output but i executed that function (in model) from the other model function. Is that a no no when it comes to the MVC structure?

I redid what i had before and this is what i have; also an error on line 24

line 24 (sendback function in model)
Code:
foreach($rows->return() as $row);

Controller
Code:
function entrytest($data) {
        $this->load->model('Entrymodel');
        $title = $this->input->post('title');
        $comment = $this->input->post('comment');
        $data = $this->Entrymodel->sendentry($title, $comment);
        
        if($data > 0){
        
        echo $data;
        $this->load->view('blogentryview', $data);
        }
        else {
            echo "there was no blogs added";
        
        }
        
    }


Model
Code:
function sendentry($title, $comment) {
        
        $query_str = "INSERT INTO entries (title, body) Value ('{$title}', '{$comment}')";

        $this->db->query($query_str, array($title, $comment));
        
        $data = $this->Entrymodel->sendback();
        
    }
        
        function sendback () {
            $data = array();
            $rows = $this->db->get('entries');
        
            if($rows->num_rows() > 0) {
            foreach($rows->return() as $row);
        
            $data[] = array('title'=>$row['title'], 'body' =>$row['body']);
            return $data;
            }
        }


Messages In This Thread
small blog help needed passing data - by El Forum - 08-11-2011, 05:06 PM
small blog help needed passing data - by El Forum - 08-11-2011, 06:30 PM
small blog help needed passing data - by El Forum - 08-12-2011, 05:58 AM
small blog help needed passing data - by El Forum - 08-12-2011, 08:06 AM
small blog help needed passing data - by El Forum - 08-12-2011, 01:30 PM
small blog help needed passing data - by El Forum - 08-12-2011, 03:26 PM
small blog help needed passing data - by El Forum - 08-12-2011, 03:31 PM
small blog help needed passing data - by El Forum - 08-12-2011, 04:02 PM
small blog help needed passing data - by El Forum - 08-12-2011, 04:39 PM
small blog help needed passing data - by El Forum - 08-12-2011, 05:04 PM
small blog help needed passing data - by El Forum - 08-12-2011, 05:15 PM
small blog help needed passing data - by El Forum - 08-12-2011, 05:31 PM
small blog help needed passing data - by El Forum - 08-12-2011, 05:42 PM
small blog help needed passing data - by El Forum - 08-12-2011, 05:46 PM
small blog help needed passing data - by El Forum - 08-12-2011, 05:48 PM
small blog help needed passing data - by El Forum - 08-12-2011, 06:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB