I found this CRUD tool it is awsome, great, superb - what everyone waited for some years and someone finally did it! Thanky!
As I am quite acquainted with PHP but totally new to Codeigniter (that is needed by GroceryCRUD I do not get the idea how I can query the databse (using Codigniter-Helpers in a Callback function. What I want to do is to check a (German) postal code that is typed in in a form and lookup the state where it is located. The needed data sits in an own table.
What I tried:
$crud->callback_before_insert(array($this,'plz_code'));
and then:
function plz_code($post_array)
{
$plz = $post_array['plz']; // $plz = $this->db->escape_str($post_array['plz']);
$ort = $post_array['ort']; // $ort = $this->db->escape_str($post_array[ort]);
$query = $this->db->query("SELECT plz, ort, land from orte WHERE PLZ = $plz and ort = $ort ");
if (count($query->row_array() > 0 )) {
$result = $query->row_array();
$plz_code = $result['Land'];
} else {
$plz_code = 'XXX';
}
$post_array['b_land'] = $plz_code;
return $post_array;
}
I hope - though it is more a Codeigniter problem (that I am totally new with) - you might help with some lines? I would appreciate it very much!
Thanks in advance,
Martin