0

I would like to show this json response data in a sectioned UItableView on my iPhone. the sections should be the first letter of the customer name.

here it is http://mobile.beger.org/getdata.php53?object=customer&mode=all

How do i have to change my mysql_fetch_object? and how do i implement it in my objective-c code?

$rs = mysql_query("SELECT LEFT(CUSTOMER_M.s_name1,1) as FirstLetter,CUSTOMER_M.i_customer_m, CUSTOMER_M.s_name1, COALESCE(CUSTOMER_M.s_town,'unbekannt') as s_town FROM `CUSTOMER_M` WHERE CUSTOMER_M.I_CUSTOMER_M > 0 ORDER BY CUSTOMER_M.S_NAME1");

while($obj = mysql_fetch_object($rs)) {

   $arr[] = $obj;
   }

echo '{"customer":'.json_encode($arr).'}';

Thanks for your help!

Christoph Beger
  • 135
  • 2
  • 14

1 Answers1

0
  1. Add a UITableViewController to your UI, implement the delegate and datasource protocols.
  2. Make an http request. to get the data.
  3. Parse the JSON. This is a good, widely used framework.

Edit

A common way to support sections is to have the datasource hold a collection of collections. Say, for json customers, an array of 26 arrays, where the inner arrays are customers with the corresponding first letter in their name. You can serve the json this way, or have the device receive a flat array and do the indexing when the data arrives.

Community
  • 1
  • 1
danh
  • 62,181
  • 10
  • 95
  • 136
  • Thanks for your answer! I basically do know what to do, but i stuck showing it in a sectioned table. i can only show it in a plain table. I think i have to change my fetch result. i need more arrays?! maybe one for each letteR? – Christoph Beger Apr 13 '12 at 05:00
  • It was hard to tell what you needed from the script snippet. And yes, about the sections, it's a collection of collections. I'll edit my answer... – danh Apr 13 '12 at 06:27