DropDownlist - no data loading - El Forum - 01-14-2011
[eluser]penta997[/eluser]
helo. I have a problem with drop down list. When I running a page, data don't displaying in web browser.
This is model code:
Code: function get_Country()
{
$query = $this->db->query('Select * from country');
return $query;
}
Controller function:
Code: function register()
{
$widok['left'] = $this->get_category();
$widok['right'] = $this->load->view('Ksiegarnia/right', '', true);
$this->load->model('Users_model');
$data['data'] = $this->Users_model->get_Country();
$widok['center'] = $this->load->view('Ksiegarnia/register_view', $data, true);
$this->load->view('Ksiegarnia/index', $widok);
}
register_view View:
Code: <div class="form">
<h1>Registration<h1>
<?php echo form_open('ksiegarnia/validation');?>
<!-- user -->
<p>Login: <?php echo form_input('username', '');?></p>
<p>Password: <?php echo form_password('pass', '');?></p>
<p>Confirm password: <?php echo form_password('pass2', '');?></p>
<?php
echo '<select name="country">';
foreach($data->result() as $item)
{
echo '<option value = "'.$item->COUNTRY_Id.'">'.$item->COUNTRY_Name.'</option>';
}
echo '</select>';
?>
<?php echo form_submit('wyslij', 'Wyślij');?>
<?php echo anchor('ksiegarnia/register', 'Zarejestruj');?>
<?php echo form_close(); ?>
</div>
DropDownlist - no data loading - El Forum - 01-14-2011
[eluser]Cristian Gilè[/eluser]
Try to comment out the call to the model and check if it works.
Is country the right name for the table? Not Country or COUNTRY?
Cristian Gilè
DropDownlist - no data loading - El Forum - 01-14-2011
[eluser]penta997[/eluser]
I've changed controller:
Code: function register()
{
$widok['left'] = $this->get_category();
$widok['right'] = $this->load->view('Ksiegarnia/right', '', true);
//$this->load->model('Users_model');
//$data['data'] = $this->Users_model->get_Country();
$widok['center'] = $this->load->view('Ksiegarnia/register_view', '', true);
$this->load->view('Ksiegarnia/index', $widok);
}
and view:
Code: <?php
$option = array('one' => 'item1', 'two'=>'item2');
echo "<select name='country'>";
foreach($option as $item):
echo "<option value = '$item'>".$item."</option>";
endforeach;
echo "</select>";
?>
And it works.
The name COUNTRY_Name is correct.
DropDownlist - no data loading - El Forum - 01-14-2011
[eluser]penta997[/eluser]
I was fixed it. It works.
|