CodeIgniter Forums
what wrong - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived General Discussion (
+--- Thread: what wrong (/showthread.php?tid=6099)

what wrong - El Forum - 02-14-2008

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:
function viwe()
$user_id = $this->session->userdata('user_id');
//connect to DB
$sql = "SELECT
user_id= '$user_id'
$query = $this->db->query($sql);
if ($query->num_rows() == 0){
$comment=array('no_list'=> 'There Are No List In The Data Base');
} else {

$row =$query->result_array();



<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;
&lt;?echo "&lt;input type='checkbox' name=\"checked[]\" value=\"$row[todo_id]\"&gt;";?&gt;
&lt;?echo $row['title']?&gt;
&lt;?echo $row['description']?&gt;
&lt;?echo $row['status']?&gt;
&lt;?echo $row['update_date']?&gt;
&lt;?echo "<a href=\"http://localhost/codeigniter/index.php/todo/to_edit\"> edit</a>" ;?&gt;
<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>

what wrong - El Forum - 02-14-2008

[quote author="mom_maj" date="1203026620"]
$row =$query->result_array();

perhaps change
$row =$query->result_array(); to $row['query'] =$query->result_array();

what wrong - El Forum - 02-14-2008

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