[eluser]mikka23[/eluser]
Well the title is extremely vague but thats because Im not sure what Im doing
. Anyways. I am receiving the following error:
Code:
Call to a member function result2() on a non-object on line 20.
Basically i am making a cms. These two php above are to edit pages currently in the database. So you go to a url with the id in the url and it displays a form with the current details which are in the database for that id. That was fine and working perfectly. Only problem was encountered when I added two new columns into my database: parent and sibling. I want a select field with the info from 'parent' for the page we are editing. Thats fine and working. The problem arises when I want to show every 'slug' for every row in the same table apart from the slug of the page we are editting and any rows where 'parent' does not equal "none"(default value for column). I do not know how to show this because I used a where clause in the database get command therefore I don't have the information from the database for any other rows apart from the one we are editting (id = uri section 4).
All help is greatly appreciated. I am a PHP noob so if you need me to explain anything a little please say as I realise my explanation is really vague.
I was previously trying:
in controller:
Code:
$this->db->where('id', $this->uri->segment(4));
$data['query'] = $this->db->get('pages');
$this->load->view('managepageview', $data);
$this->db->where('parent', 'none');
$pdata['parental'] = $this->db->get('pages');
$this->load->view('managepageview', $pdata);
in managepageview:
Code:
<?php
foreach($query->result() as $row){
echo "<h2>Manage Page - $row->title</h2>";
echo form_open('admin/pages/managepage');
echo "<h4>Title</h4>
<input type='text' id='title' name='title' value='$row->title' size='50' />
<h4>Slug</h4>
<input type='text' id='slug' name='slug' value='$row->slug' size='50' />
<h4>Content</h4>
<textarea id='content' name='content' cols='80' rows='15'>";
echo ( htmlentities($row->content));
echo "</textarea>
<h4>Parent:</h4>
<select name='parent'>
<option value=' <$row->parent'>$row->parent</option>";
foreach($parental->result() as $bow){
echo "<option value='$bow->slug'>$bow->slug</option>";
}
echo "</select>
<input name='id' type='hidden' value=' $this->uri->segment(4); ?>'>
<p><input type='submit' value='Update' /></p>
</form>";
echo form_open('admin/pages/deletepage');
echo "<input name='id2' type='hidden' value='";
echo $this->uri->segment(4);
echo "'><p>If you want to delete the page click the button below:</p>
<p><input type='submit' value='Delete' /></p>
</form>";
}
?>
It doesn't show anything for the second set of results however, apart from this part it works perfectly:
Quote:<?php foreach($parental->result() as $bow):?>
<option value=" <?=$bow->slug?>"><?=$bow->slug?></option>
<?php endforeach; ?>