Jump to content


How order alphabetically

uppercase lowercase grocery grocery crud mysql php

  • Please log in to reply
4 replies to this topic

#1 versace123mx

versace123mx

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 28 March 2017 - 08: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.



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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 :)



#3 versace123mx

versace123mx

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 29 March 2017 - 04: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


#4 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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 :)



#5 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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 :)







Also tagged with one or more of these keywords: uppercase lowercase grocery, grocery crud, mysql, php

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users