[eluser]GamingFusion[/eluser]
Im trying to get my app to update data in the database. When i submit the changes it says successful and lists the changes made. But when i go to the database it hasnt changed.
Whats Wrong?
heres all my code to do with this part of the app.
model
Code:
//Show Update Function
function updateShow($id)
{
$data = array('title' => $this->input->post('title'), 'desc' => $this->input->post('desc'), 'showtimes' => $this->input->post('times'), 'cast' => $this->input->post('cast'), 'director' => $this->input->post('director'));
$this->db->where('id', $id);
$query = $this->db->update('shows', $data);
if ($query) {
return $data['updated'] = TRUE;
return $query;
}else{
return $data['updated'] = FALSE;
}
}
View - updateShow.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?=$title?></title>
</head>
<body>
<?php
if ($updated = TRUE) {
$title = $this->input->post('title');
$desc = $this->input->post('desc');
$times = $this->input->post('times');
$cast = $this->input->post('cast');
$direct = $this->input->post('director');
echo '<h1>Success!</h1>
<h3>The Show has been edited!</h3>';
echo '<b>Show Title: </b><br />', $title, '<br /><br />';
echo '<b>Show Description: </b><br />', $this->typography->nl2br_except_pre($desc), '<br /><br />';
echo '<b>Show Times: </b><br />', $this->typography->nl2br_except_pre($times), '<br /><br />';
echo '<b>Cast: </b><br />', $this->typography->nl2br_except_pre($cast), '<br /><br />';
echo '<b>Director: </b><br />', $direct, '<br />';;
}else{
echo '<h1>Failure!</h1>
<h3>The Show was not been updated.</h3>';
}
?>
</body>
</html>
view - editShow.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?=$title?></title>
</head>
<body>
<?=form_open('theater/updateShow');?>
<table>
<tr>
<td>Show Title: </td><td><input name="title" class="input" type="text" value="<?=$query->title?>" /></td>
</tr>
<tr>
<td>Show Description: </td><td><textarea name="desc" class="input" cols="30" rows="5"><?=$query->desc?></textarea></td>
</tr>
<tr>
<td>Show Times: </td><td><textarea name="times" class="input" cols="30" rows="5"><?=$query->showtimes?></textarea></td>
</tr>
<tr>
<td>Cast: </td><td><textarea name="cast" class="input" cols="30" rows="5"><?=$query->cast?></textarea></td>
</tr>
<tr>
<td>Director: </td><td><input name="director" class="input" type="text" value="<?=$query->director?>" /></td>
</tr>
<tr>
<td><?=form_submit('submit', 'Update Show');?></td><td><?=form_reset('reset', 'reset');?></td>
</tr>
</table>
</form>
</body>
</html>