How to populate spinner from mySql database

Posted by user1472085 on Stack Overflow See other posts from Stack Overflow or by user1472085
Published on 2012-06-22T09:12:22Z Indexed on 2012/06/22 9:15 UTC
Read the original article Hit count: 308

Filed under:
|

How do i populate this,I have 2 Spinners in my app and one is for Province and other is for City, when i select Gauteng in province spinner i want my second spinner to show Johannesburg,Pretoria,Centurion and If i select KZN in province i want my second spinner to show Maritsburg and Durban.

im using mySql database and i have Province table and City table. Here is My Province table(idprovince,provincename)

1   Gauteng 
2   Free-State 
3   Limpopo 
4   Northen-Cape 
5   North-West 
6   Western-Cape 
7   Eastern-Cape 
8   Kwa-Zulu-Natal 
9   Mpumalanga 

and Here is my city table(idcity,cityname,province_idprovince)

1  Johannesburg    1 
2   pretoria    1 
3   Centurion   1 
4   Bloemfontein    2 
5   Welkom  2 
6   Polokwane   3 
7   Phalaborwa  3 
8   Potgiersrus 3 
9   Tzaneen 3 
10  Kimberley   4 
11  Upington    4 
12  Mafikeng    5 
13  Klerksdorp  5 
14  Mmabatho    5 
15  Potchefstroom   5 
16  Brits   5 
17  Cape-Town   6 
18  Stellenbosch    6 
19  George  6 
20  Saldhana-Bay    6 
21  Bisho   7 
22  Port-Elizabeth  7 
23  East-London 7 
24  Pietermaritzburg    8 
25  Durban  8 
26  Ulundi  8 
27  Richards-Bay    8 
28  Newcastle   8 
29  Nelspruit   9 
30  Witbank 9 
31  Middleburg  9 
32  Ermelo  9

i will appriciate your help.

© Stack Overflow or respective owner

Related posts about android

Related posts about mysql