2012-04-12 4 views
0

my mysql 데이터베이스에서 고객 데이터를 수신합니다. 모든 고객을 단면 표보기로 표시하고 싶습니다. 각 섹션의 제목은 고객 이름의 첫 글자이고 각 섹션의 numberOfrows는 동일한 문자로 시작하는 고객의 수입니다. 기본적으로 그것은 내 아이폰에 내 연락처 애플 리케이션처럼 보일 것입니다.sectionedTableView iPhone의 JSON 데이터

여기 난 내있는 tableView에서 모든 고객을 표시 할 수 있습니다 내 데이터 지금

http://mobile.beger.org/getdata.php53?object=customer&mode=all입니다. 어떻게 고객을 섹션에 배치 할 수 있습니까? 내 mysql select를 편집해야합니까? 아니면 두 개의 json 문자열이 있어야합니다. 이 편지로 시작하는 각 편지와 고객 수에 하나는 고객 정보가있는 다른 하나입니까?

도움 주셔서 감사합니다.

답변

0

쉽고 저렴한 솔루션을 위해이 종류의 블록을 사용하고 있습니다. 웹 서비스 응답을 편집했습니다. 이것을 봐주세요.

{ 
    "customer": [ 
    { "A": [ 
     { 
     "i_customer_m": "22", 
     "s_name1": "Amann Solutions AG", 
     "s_town": "Herisau" 
     }, 
     { 
     "i_customer_m": "5", 
     "s_name1": "Architekturhaus Leibold GmbH", 
     "s_town": "D\u00fcnkelsried" 
     }, 
     { 
     "i_customer_m": "68", 
     "s_name1": "ATEcare Service GmbH & Co.KG", 
     "s_town": "Aichach" 
     }, 
     { 
     "i_customer_m": "83", 
     "s_name1": "Autohandel Polska GmbH", 
     "s_town": "Prag" 
     }, 
     { 
     "i_customer_m": "65", 
     "s_name1": "Autohandel Polska GmbH", 
     "s_town": "Prag" 
     } 
    ]}, 
    {"B": [ 
     { 
     "i_customer_m": "45", 
     "s_name1": "Baugenossenschaft Strassbourgh", 
     "s_town": "Strassbourgh" 
     }, 
     { 
     "i_customer_m": "11", 
     "s_name1": "Baugenossenschaft Wien", 
     "s_town": "Wien" 
     }, 
     { 
     "i_customer_m": "1", 
     "s_name1": "Betzy AG", 
     "s_town": "Germering, Oberbayern" 
     }, 
     { 
     "i_customer_m": "46", 
     "s_name1": "BSG", 
     "s_town": "Herrsching am Ammersee" 
     }, 
     { 
     "FirstLetter": "B", 
     "i_customer_m": "67", 
     "s_name1": "BVVS Systemhaus GmbH", 
     "s_town": "M\u00fcnchen" 
     } 
    ]} 
    ] 
} 

감사합니다,이에서

+0

우리는 또한 데이터 중복을 줄일 수 있습니다. 그리고 더 빨리 응답하십시오. – MinuMaster

+0

답변 해 주셔서 감사합니다. 그래서 어떻게 내 mysql/php 코드를 자신의 것으로 변경해야합니까? 여기에 $ rs = mysql_query ("FirstLetter, CUSTOMER_M.i_customer_m, CUSTOMER_M.s_name1, COALESCE (CUSTOMER_M.s_town, 'unbekannt')를 s_town으로 선택하십시오. FROM'CUSTOMER_M' WHERE CUSTOMER_M.I_CUSTOMER_M > 0 ORDER BY CUSTOMER_M.S_NAME1 "); while ($ obj = mysql_fetch_object ($ rs)) { \t $ arr [] = $ obj; } echo '{ "고객":'. json_encode ($ arr). '}' '; –

+0

JSON을 코드로 형식을 지정하십시오 (강조 표시하고'{}'버튼을 누르십시오). 그런 식으로 서식이 보존됩니다 (이 경우 이미 당신을 위해했습니다). – JeremyP