Home >Backend Development >PHP Tutorial > 关于省市二级联动乱码的有关问题!

关于省市二级联动乱码的有关问题!

WBOY
WBOYOriginal
2016-06-13 13:35:21930browse

关于省市二级联动乱码的问题!急!!!在线等
利用php+mysql+jquery完成类似省市二级联动的问题 ,就是学院下有不同的班级,功能已完成就是选择学院后再选班级是乱码的,改了很多得编码类型,单独测试班级的页面是正常的,请问这是什么出了问题??

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><?php Header("Content-type:text/html;charset=GBK");
    $conn=mysql_connect("localhost","root","");
    mysql_select_db("openlab");
    mysql_query("set names utf8");
    $sql="select * from class where fatherid=".$_GET['academy_id'];
    $query=mysql_query($sql);
    while($row=mysql_fetch_array($query)){
        $class[]=$row;
    }
?>
<select id="class" name="student_class">
    <option value="0">请选择班级</option>
    <?php foreach($class as $k=>$v){
            $v['class_name']=iconv ('utf-8','GBK', $v['class_name']); 
    ?>    
         <option value="<?php echo $v[" class_id>'><?php echo $v['class_name']?>
</option>
    <?php }
    ?>
</select>

这是班级的页面!!!

------解决方案--------------------
“下再次重启还是原来的代码就正常了”,浏览器缓存
你需要在php输出取出缓存的头

------解决方案--------------------
尽量保持,文件本身编码,数据库,页面输出内容编码,一致。出现乱码的问题就不大了
------解决方案--------------------
函数:20.function changelocation(locationid)
21.{
22.document.myform.ctype.length = 0;
23.var locationidlocationid=locationid;
24.var i;
25.for (i=0;i 26.{
27.if (subcat[i][2] == locationid)
28.{
29.//var newnewOption1=new Option(subcat[i]
[1], subcat[i][0]);
30.//document.all.ctype.add(newOption1);
31.document.myform.ctype.options[document.
myform.ctype.length] = new Option(subcat
[i][1], subcat[i][0]);
32.}
33.}
34.}
具体请参考:http://www.phpnewer.com/index.php/Ymgx/detail/id/30
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn