⚠ In case you've missed it we are migrating to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


Member Since 19 Sep 2012
Offline Last Active Sep 20 2012 08:01 PM

Topics I've Started

Want to sql my own table in a callback function - how?

19 September 2012 - 03:05 PM

Hi there,

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:


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,