[eluser]Unknown[/eluser]
I am writing a form that's on the back-end admin that displays a list of businesses. Right now, I've built the part where it displays the businesses from the db and keeps them checked. I am trying to to get the form to insert a 1 or 0 in the display column in the db and return checked or unchecked depending on whether or not the the boxes in the view are checked - display 1. unchecked - display 0.
Here's my code:
Controller:
Code:
<?php
class whats_nearby extends Controller {
function index()
{
}
function whats_nearby()
{
parent::Controller();
$data['types'] = $this->artslookup->get_all_by_type('businessType');
$this->load->model('lookup_model');
if($this->input->post('businessType'))
{
$this->lookup_model->update_whatsnearby($this->input->post('businessType'));
$data['showConfirm'] = TRUE;
}
$this->load->view('admin/whats_nearby/index',$data);
}
}
?>
Model:
Code:
function update_whatsnearby($lookup)
{
$data = array(
'title' => $title,
'name' => $name,
'date' => $date
);
$this->db->where('id', $id);
$this->db->update('mytable', $data);
}
}
View:
Code:
<?
$this->load->view('/admin/header');
?>
<?
$this->load->view('/admin/nav-column');
?>
<div id="main_column">
<h2>What's NearBy</h2>
<? if (isset($_POST['Submit_x']) && isset($_POST
['submit_y'])) {
printf('<h1> You Clicked at the following coordinates: x-%s, y-%s</h1>',
($_POST ['Submit_x']),
($_POST ['Submit_y'])
);
} else {
?>
<form method="post" action=" <?php
echo ($_SERVER['PHP_SELF']); ?>">
<? while(list($key,$thisType) = each($types)): if ($thisType['display'] != '0')
echo '<br><input type=checkbox name="businessType[]" checked>' ?>
<? if(in_array($key,$thisType['lookupType']))echo 'checked'; ?>
<?=$thisType['lookupType']?>
<? endwhile; ?>
<br>
<br>
<br>
<input type="image" name= "Submit" src="/images/button_submit_changes.gif">
</form>
<?
}
?>
<? if ($this->config->item('enable_profiler')) $this->output->enable_profiler(true); ?>
<?
$this->load->view('/admin/footer');
?>
If you can help I would really appreciate it. I've been hung up on this for a while now.