[eluser]edjon2000[/eluser]
Hello again
I am rewriting my web project to take into account CI Reactor and making a few design improvements on the way, however, I have run into a problem which for the life of me I cannot understand.
I will try to break it down as best as I can:-
Initially I created a method to generate values for a dropdown list and have since extended that to include some other pages on this project, so far, everything has worked out correctly, apart from this one variation( I do a lot of copying and pasting and just change the variables - as you will see shortly -
)
Here is the method that works correctly:-
Code:
// under development
function create_vacancy_list()
{
$vacancies = array();
$vacancy_values = NULL;
$vacancy_keys = NULL;
$this->db->select('name');
$this->db->distinct();
$this->db->order_by('name');
$vacancies = $this->db->get('tbl_vacancies');
if ($vacancies->num_rows() > 0)
{
foreach ($vacancies->result() as $vacancy)
{
$vacancy_keys[] = $vacancy->name;
$vacancy_values[] = $vacancy->name;
}
$query = array_combine($vacancy_keys, $vacancy_values);
}
// echo '<pre>';
// print_r($query);
// echo '</pre>';
// die('script stopped');
return $query;
}
and this is the one that does not work
Code:
// under development
function create_client_list()
{
$clients = array();
$client_values = NULL;
$client_keys = NULL;
$this->db->select('name');
$this->db->distinct();
$this->db->order_by('name');
$clients = $this->db->get('tbl_clients');
if ($clients->num_rows() > 0)
{
foreach ($clients->result() as $client)
{
$client_keys[] = $client->name;
$client_values[] = $client->name;
}
$query = array_combine($client_keys, $client_values);
}
As you can see, they are virtually identical but for some reason the "create_client_list method" does not work.
I could be missing something obvious and I apologise if I have, I have been trying to sort this out for the past four hours so I could be a bit "punch-drunk".
Anyway this is the error I am getting:-
Code:
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: helpers/form_helper.php
Line Number: 324
So any advice about this would be greatly appreciated
Jon