Hello,
I am trying to create a new theme copying and editing flexigrid theme.
With simple inputs, all is ok and fields are saved but now I am trying something else.
I am trying to create a dropdown from the database...
If I use a model I have this error...
A PHP Error was encountered Severity: Notice Message: Undefined property: Grocery_CRUD::$Model_propiedades Filename: views/add.php
And if I try to include the model code in add.php, I have the following error:
A PHP Error was encountered Severity: Notice Message: Undefined property: Grocery_CRUD::$db Filename: views/add.php
The code in the model is:
public function listaprovincias() { $provincias=''; $sql = $this->db->query("SELECT * FROM gnr_provincias ORDER BY provincia ASC"); $query = $this->db->query($sql); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $provincias .= '<option value="'.$row->provincia.'">'.$row->provincia.'</option>'; } } return $provincias; }
And in Add.php, I have the following:
<label>Provincia</label> <select name="propiedades_provincia"> <?php $listaprovincias = $this->Model_propiedades->listaprovincias(); echo $listaprovincias; ?> </select>
Can somebody help me? how can I use a model from Add.php or connect to the database?
Thank you.