function subKategori($str){
global $koneksi;
$A = $str;
$A1 = mysqli_query($koneksi, "select * from kategori where sub_id='".$A."'");
$A2 = mysqli_num_rows($A1);
if($A2 != 0){
while($A3 = mysqli_fetch_array($A1)){
$query1 = 'or id_kategori='.$A3['id'].' ';
$query = ''.subKategori($A3['id']).' '.$query1.' '; //variable 1
}
}else{}
}
$idKategori = 1;
subKategori($idKategori);
$output = $query; //output variable 1
我想从外面获取变量...
因为,如果我使用subKategori();在mysqli_query()上,它显示了......
像
mysqli_query($connection, "Select * from item where id_category="'.$idKategori."' $output");
答案 0 :(得分:1)
return
是你的朋友。
function Test(){
return "AAAAHHH";
}
Echo Test(); // Output "AAAAHHH"