[eluser]Mohammed Zayan[/eluser]
I use this code in the view file
Code:
<br />
<div class="cblock">
<?php
$id = $this->uri->segment(3);
if(isset($message)){
echo "<h3>" . $message . "</h3>";
}
?>
<div class="headmenu">Add Translation</div>
<div class="bodymenu">
<?php echo form_open("cats/add_cat_translation/$id"); ?>
<table class="tabl">
<tr class="a">
<td><?php echo form_label('Language: ', 'language'); ?></td>
<td>
<select name="language">
<?php foreach($rows as $row){ ?>
<option value="<?php echo $row->id; ?>"><?php echo $row->description; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr class="b">
<td><?php echo form_label('Catg Name: ', 'name'); ?></td>
<?php $data = array('name' => 'name', 'id' => 'name', 'size' => 40, 'value' => set_value('name')); ?>
<td><?php echo form_input($data); ?></td>
</tr>
</table>
<br />
<input type="submit" name="submit" class="buton" value="Save" />
<a href="<?php echo base_url(); ?>cats/cats_" class="links">Back</a>
<?php echo form_close(); ?>
</div>
</div>
And this is the controller code
Code:
function add_cat_translation(){
$query = $this->cats_model->addCatTranslation();
if($query){
$data['message'] = 'Added!';
$q = $this->languages_model->getLangData();
if($q){
$data['results'] = $q;
}
$data['main_content'] = 'cats/add_translation_view';
$this->load->view('includes/template', $data);
}
}
and this is the code in cats_model
Code:
function addCatTranslation(){
$data = array(
'id' => NULL,
'book_cat_id' => $this->uri->segment(3),
'language_id' => $this->input->post('language'),
'description' => $this->input->post('name')
);
$sql = $this->db->insert('book_cat_translation', $data);
if($sql){
return TRUE;
}
}
and this is the code in languages_model
Code:
function getLangData(){
$sql = "SELECT `id`, `description` FROM `language`";
$query = $this->db->query($sql);
if($query->num_rows > 0){
return $query->result();
}
}
when I add a translation in book_cat_translation table I have this result at the photo
http://im28.gulfup.com/2012-05-05/1336223191601.jpg
it add 4 rows contan zeros after my insert
I don't know what is wrong.
So, someone tell me please.