Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter - Not working to pass array to view
    primarykey
    data
    text
    <p>I don't understand why this is not putting the database values on the page. Can you please tell me what I am doing wrong with this code? I'm a novice at CodeIgniter and this is the first time I'm trying to pass an array from model to controller to view.</p> <p>Controller Code:</p> <pre><code>public function showuser(){ $id = $this-&gt;uri-&gt;segment(3); $this-&gt;load-&gt;model('user_model'); $data['user']= $this-&gt;user_model-&gt;view_user($id); $this-&gt;load-&gt;view('include/header'); $this-&gt;load-&gt;view('user_view',$data); $this-&gt;load-&gt;view('include/footer'); } </code></pre> <p>Model Code:</p> <pre><code>public function view_user($id){ $this-&gt;db-&gt;where('userid', $id); $query = $this-&gt;db-&gt;get('users'); return $query-&gt;result(); } </code></pre> <p>View Code:</p> <pre><code>&lt;table width="300" border="0" cellpadding="2"&gt; &lt;tr&gt; &lt;td width="143"&gt;First Name&lt;/td&gt; &lt;td width="143"&gt;&lt;?php echo $data['user']-&gt;firstname; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Last Name&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;lastname; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Company&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;company; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Email&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;email; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Phone&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;phone; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;p&gt;Fax&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;fax; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Address 1&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;address1; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;p&gt;Address 2&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;address2; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Address 3&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;address3; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;City&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;city; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;State/Region/Province&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;state; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Postal Code&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;zipcode; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Username&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;username; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Account Type&lt;/td&gt; &lt;td&gt;&lt;?php echo $data-&gt;usertype; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload