city.inc.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * [³¬¼¶»î¶¯(xj_event.{modulename})] (C)2012-2099 Powered by åÐÒ£¹¤×÷ÊÒ.
  4. * Version: 1.0
  5. * Date: 2012-9-15 10:27
  6. */
  7. if(!defined('IN_DISCUZ')) {
  8. exit('Access Denied');
  9. }
  10. if($_GET['level']){
  11. $province = intval($_GET['province']);
  12. $city = intval($_GET['city']);
  13. $county = intval($_GET['county']);
  14. $query = DB::query("SELECT * FROM ".DB::table('common_district')." WHERE level = 1 order by id");
  15. $result = '<select id="province" name="province"><option>-'.lang('plugin/xj_event', 'chenshi').'-</option>';
  16. while($value = DB::fetch($query)){
  17. $result .= '<option value="'.$value['id'].'" '.($value['id']==$province?'selected':'').'>'.$value['name'].'</option>';
  18. }
  19. $result .= '</select>';
  20. if($province){
  21. $query = DB::query("SELECT * FROM ".DB::table('common_district')." WHERE level = 2 AND upid=$province order by id");
  22. $result .= '<select id="city" name="city"><option>-'.lang('plugin/xj_event', 'chenshi').'-</option>';
  23. while($value = DB::fetch($query)){
  24. $result .= '<option value="'.$value['id'].'" '.($value['id']==$city?'selected':'').'>'.$value['name'].'</option>';
  25. }
  26. $result .= '</select>';
  27. }
  28. if($city){
  29. $count = DB::result_first("SELECT count(*) FROM ".DB::table('common_district')." WHERE level = 3 AND upid=$city");
  30. if($count){
  31. $query = DB::query("SELECT * FROM ".DB::table('common_district')." WHERE level = 3 AND upid=$city order by id");
  32. $result .= '<select id="county" name="county"><option>-'.lang('plugin/xj_event', 'zhouxian').'-</option>';
  33. while($value = DB::fetch($query)){
  34. $result .= '<option value="'.$value['id'].'" '.($value['id']==$county?'selected':'').'>'.$value['name'].'</option>';
  35. }
  36. $result .= '</select>';
  37. }
  38. }
  39. if($county){
  40. $count = DB::result_first("SELECT count(*) FROM ".DB::table('common_district')." WHERE level = 4 AND upid=$county");
  41. if($count){
  42. $query = DB::query("SELECT * FROM ".DB::table('common_district')." WHERE level = 4 AND upid=$county order by id");
  43. $result .= '<select id="town" name="town"><option>-'.lang('plugin/xj_event', 'xiangzhen').'-</option>';
  44. while($value = DB::fetch($query)){
  45. $result .= '<option value="'.$value['id'].'">'.$value['name'].'</option>';
  46. }
  47. $result .= '</select>';
  48. }else{
  49. $result .= '<!--end-->';
  50. }
  51. }
  52. exit($result);
  53. }else{
  54. $upid = intval($_GET['upid']);
  55. if($upid){
  56. $city = DB::fetch_all("SELECT * FROM ".DB::table('common_district')." WHERE upid = $upid");
  57. }else{
  58. $province = DB::fetch_all("SELECT * FROM ".DB::table('common_district')." WHERE level = 1 order by id");
  59. }
  60. include template('xj_event:city');
  61. }
  62. ?>