infobih
Posts: 58
|
| Posted: 07/27/2010, 2:10 AM |
|
Hello
I have one Grid with one field called "flags". This field contains string like
- - - ? - - - - H - or
- D - - - - - - - - etc etc
I have created one label named "flag"
How can I acheive to display in label only one letter from string "flags" (Before Show Event)
For example if field "flags" value is - D - - - - - - - - then display "D" in this label, otherwise another letter;
Thank you very much in advance
|
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 08/15/2010, 7:42 AM |
|
infobih,
Are you grabbing a specific character from the flags field?? If so, you could use a php function( substr(string,start,length) ) or a mysql function ( LEFT(str,len) and make it a part of your datasource ).
|
 |
 |
infobih
Posts: 58
|
| Posted: 08/15/2010, 8:14 AM |
|
Hi mamboBROWN
Yes,it is exactly what I want. In my example I need to get letter "H" for string - - - ? - - - - H - , or letter "D" for string - D - - - - - - - -
How can I create loop case with that function?
Thanks
|
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 08/15/2010, 8:47 AM |
|
infobih,
Is there a set position that you are grabbing the character from or does it always vary?
|
 |
 |
infobih
Posts: 58
|
| Posted: 08/15/2010, 9:05 AM |
|
Grid = "mygrid"
Field concerned in the Grid named "flags", i've got from database
I have only three different strings, always the same order of characters
---?----H-
---Z------
-D--------
I need to display H, D, Z from the string in the field "flags" depending of the value from database.
Thank you in advance
|
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 08/15/2010, 10:10 AM |
|
infobih,
Add the bolded section to your MySQL query:
select case when instr(flag,'H')>0 then 'H' when instr(flag,'Z')>0 then 'Z' when instr(flag,'D')>0 then 'D' else ' ' end as Theflag from gridtable
KEY: flag is the string field, gridtable is the table name, Theflag is the query field name.
Depending on what case is true it will return eith H, Z or D.
|
 |
 |
infobih
Posts: 58
|
| Posted: 08/15/2010, 11:06 AM |
|
Thank yoy mamboBROWN
Ii works very well with 20K records table.
|
 |
 |
|