⚠ In case you've missed it, we have migrated 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 is an archived forum. ⚠

  •     

profile picture

How order alphabetically



versace123mx

versace123mx
  • profile picture
  • Member

Posted 28 March 2017 - 20:47 PM

I have a doubt, I need to sort the fields by the field name alphabetically, but it turns out that the data in the db ones are in uppercase and others in lowercase, so I do not order the correct form, when I show the data in a Table with grocery crud, you'll have some idea of what I can do.

 

 

$crud->order_by('nombre_completo','asc');

 

This only works for me when the data is stored in the same way, but when some are saved in Hello, hello it does not work for me

 

 

I already solved the problem in half, since the data in the db are saved with spaces and that generates problems, I require that before sending the data, these are saved without spaces, but I do not know how to implement it with a Function on a field or how to do it.


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 29 March 2017 - 07:02 AM

Hi,

 

You can use the following..

Didnt try it .. never needed to but its worth it..

 

$crud->order_by('LOWER(nombre_completo)','asc');

 

Hope - that works for u

 

Happy GCing :)


versace123mx

versace123mx
  • profile picture
  • Member

Posted 29 March 2017 - 16:54 PM

Many thanks, I will implement it later if I have problems again, for now I was solved, since my problem was because the data in the database were saved with spaces.
 
What I would like to know is how to remove the spaces before sending the data to the data base.
 
thank you very much

Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 30 March 2017 - 07:02 AM

well.. while u set the value for the field ... insted of setting 'key' => $value .. u can set it ----- $key => trim($value)

 

Trimming it will ensure the values are all trimed before it reaches the db.

 

Happy GCing :)


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 30 March 2017 - 07:18 AM

well.. while u set the value for the field ... insted of setting 'key' => $value .. u can set it ----- $key => trim($value)

 

Trimming it will ensure the values are all trimed before it reaches the db.

 

Happy GCing :)