Welcome Guest, Not a member yet? Register   Sign In
passing an array to form - update
#1

[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>


&lt;? 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 {
?&gt;
&lt;form method="post" action=" &lt;?php
echo ($_SERVER['PHP_SELF']); ?&gt;"&gt;
&lt;? while(list($key,$thisType) = each($types)): if ($thisType['display'] != '0')
echo '<br>&lt;input type=checkbox name="businessType[]" checked&gt;' ?&gt;

&lt;? if(in_array($key,$thisType['lookupType']))echo 'checked'; ?&gt;
&lt;?=$thisType['lookupType']?&gt;
&lt;? endwhile; ?&gt;

<br>
<br>
<br>
&lt;input type="image" name= "Submit" src="/images/button_submit_changes.gif"&gt;
&lt;/form&gt;
&lt;?
    }
?&gt;
&lt;? if ($this->config->item('enable_profiler')) $this->output->enable_profiler(true); ?&gt;

&lt;?
$this->load->view('/admin/footer');
?&gt;



If you can help I would really appreciate it. I've been hung up on this for a while now.


Messages In This Thread
passing an array to form - update - by El Forum - 09-24-2008, 01:50 PM
passing an array to form - update - by El Forum - 09-24-2008, 03:55 PM
passing an array to form - update - by El Forum - 09-24-2008, 04:23 PM
passing an array to form - update - by El Forum - 09-24-2008, 05:32 PM
passing an array to form - update - by El Forum - 09-24-2008, 11:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB