Home  >  Article  >  Backend Development  >  怎样才能把全部的结果都输出

怎样才能把全部的结果都输出

WBOY
WBOYOriginal
2016-06-13 12:30:281001browse

怎样才能把所有的结果都输出?
用ajax的post方法请求数据,回调函数里面怎样才能取出全部的数据。PS:(数据库里有多条数据 我这样写只能取出最后一条。)
前段代码:
$(document).ready(function() {    
var submitData={  
action:"SELECT",  
};
$.post("../data/product_edit.php",submitData,function(data){ 
alert(data.product_type); 
},"json");  
});
后台代码:
 dbconn();  
$ACTION=$_POST['action'];   
switch($ACTION) {       
case "SELECT":  
$sql="SELECT CLASSNAME FROM product_type";  
$rs=mysql_query($sql);  
while($row=mysql_fetch_array($rs)){   
 $arr=array(    
 'product_type'=>$row['CLASSNAME'],   
); 
 } 
} $json_string = json_encode($arr);    
echo $json_string;    
dbclose();
?>

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