Hello,
Can anyone help me do this? This is my add_pages form which I would like to use for editing also.
Therefore if someone from pages.php click button add the below add_pages.php form appears with empty form and if the user click edit button. The previous data will loads in add_pages.php
in value="" therefore should be an if statement.
If someone click edit button --> therefore should be a certain value in value="". How to write the correct if statement or code?
Thanks in advance.
views/add_pages.php
PHP Code:
<table border="0" style="width: 100%; height: 90px;">
<tr>
<td>Pages Name:</td>
<td><input type="input" name="pages_name"
value="
<?php
echo $this->pages_model->get_pages();
?>
></td>
</tr>
<!--
<tr>
<td>Create Date:</td>
<td><input type="input" name="create_date" size="2"></td>
</tr> -->
<tr>
<td>Order:</td>
<td><input type="input" name="pages_order" size="4"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Submit" /></td>
</tr>
</table>
controllers/cpages.php
PHP Code:
public function addpages()
{
$this->form_validation->set_rules('pages_name', 'pages_name', 'required');
$this->form_validation->set_rules('create_date', 'create_date', 'required');
$this->form_validation->set_rules('pages_order', 'pages_order', 'required');
$this->form_validation->set_rules('pages_content', 'pages_order', 'required');
if ($this->form_validation->run() === FALSE)
{
$this->load->view('add_pages');
}
else
{
$this->pages_model->insert_pages();
$this->load->view('add_pages');
}
}
public function editpages()
{
$data['show'] = $this->pages_model->get_pages();
$this->load->view('add_pages', $data);
}
" If I looks more intelligence please increase my reputation."