what wrong |
[eluser]mom_maj[/eluser]
thats code performed i bring many row from DB and pass it to view page ,it give me error and that is : A PHP Error was encountered Severity: Notice Message: Undefined variable: row Filename: views/view.php Line Number: 16 my cod is: model: function viwe() { $this->user_model->islogin(); $user_id = $this->session->userdata('user_id'); //connect to DB $sql = "SELECT * FROM list WHERE user_id= '$user_id' "; $query = $this->db->query($sql); if ($query->num_rows() == 0){ $this->load->view('view'); $comment=array('no_list'=> 'There Are No List In The Data Base'); $this->load->vars($comment); } else { $row =$query->result_array(); $this->load->view('view',$row); } } view: <?php ?> <html> <form method="POST" action="delete"> <table border='1'> <tr><th>X</th> <th>Title</th> <th>Description</th><th>Status</th><th>Date</th><th>Action</th></tr> <?echo 'This Is The List Of Your Order';?> <?php foreach ($query->result_array() as $row) {?> <tr><td> <?echo "<input type='checkbox' name=\"checked[]\" value=\"$row[todo_id]\">";?> </td><td> <?echo $row['title']?> </td><td> <?echo $row['description']?> </td><td> <?echo $row['status']?> </td><td> <?echo $row['update_date']?> </td><td> <?echo "<a href=\"http://localhost/codeigniter/index.php/todo/to_edit\"> edit</a>" ;?> </td></tr> <?}?> </form> <table> <tr><td><input type="submit" value="Delete Todo"></td> <td align="center"><a href = http://localhost/codeigniter/index.php/todo/back>GO back</a></td></tr> </table> </html>
[eluser]mooger[/eluser]
[quote author="mom_maj" date="1203026620"] $row =$query->result_array(); $this->load->view('view',$row); [/quote] perhaps change $row =$query->result_array(); to $row['query'] =$query->result_array();
[eluser]Rick Jolly[/eluser]
yep, then in your view: Code: foreach ($query as $row) |
Welcome Guest, Not a member yet? Register Sign In |