Welcome Guest, Not a member yet? Register   Sign In
what wrong
#1

[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>
&lt;?echo 'This Is The List Of Your Order';?&gt;
&lt;?php foreach ($query->result_array() as $row) {?&gt;
<tr><td>
&lt;?echo "&lt;input type='checkbox' name=\"checked[]\" value=\"$row[todo_id]\"&gt;";?&gt;
</td><td>
&lt;?echo $row['title']?&gt;
</td><td>
&lt;?echo $row['description']?&gt;
</td><td>
&lt;?echo $row['status']?&gt;
</td><td>
&lt;?echo $row['update_date']?&gt;
</td><td>
&lt;?echo "<a href=\"http://localhost/codeigniter/index.php/todo/to_edit\"> edit</a>" ;?&gt;
</td></tr>
&lt;?}?&gt;
&lt;/form&gt;
<table>
<tr><td>&lt;input type="submit" value="Delete Todo"&gt;</td>
<td align="center"><a href = http://localhost/codeigniter/index.php/todo/back>GO back</a></td></tr>
</table>
&lt;/html&gt;
#2

[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();
#3

[eluser]Rick Jolly[/eluser]
yep, then in your view:
Code:
foreach ($query as $row)




Theme © iAndrew 2016 - Forum software by © MyBB