Warning: mysqli_query() expects parameter 1 to be mysqli, null given
<?php
require_once('connect.php');
function getList($pid=0,&$result=array(),$spac=0){
$spac = $spac + 2;
$sql="select * from forwardcate WHERE pid='$pid' ";
$query=mysqli_query($con,$sql);
if($query&&mysqli_num_rows($query)){
while($row = mysqli_fetch_assoc($query)){
$row['catename'] = str_repeat(' ',$spac).'|--'.$row['catename'];
$result[] = $row;
getList($row['id'],$result,$spac);
}
}
return $result;
}
function displayCate($pid=0,$selected=1){
$rs = getList($pid);
$str='';
$str.= "<select name='cate'>";
foreach($rs as $key => $val){
$selectedstr = '';
if($val['id'] == $selected){
$sellectedstr ="selected";
}
$str.= "<option {$selectedstr}>{$val['catename']}</option>";
}
return $str .= '</select>';
}
echo displayCate(0,1);
?>