我想在getStaffListByID函数的循环中调用getStaffListByLID函数,但是到getStaffListByLID里貌似lid的值没有传过来,请问怎么办?function getStaffListByID($con){
global $idn,$id,$pic,$name;
$sel = "select id,pic,name from student;";
$ret = pg_Exec($con,$sel);
$idn = pg_NumRows($ret);
for ( $i=0; $i<$idn; $i++ ) {
$id[$i] = pg_Result($ret, $i, "id");
echo '$id[$i]'.$id[$i];
$lid = $id[$i];
getStaffListByLID($con,$lid);
$pic{$id[$i]} = pg_Result($ret, $i, "pic");
$name{$id[$i]} = pg_Result($ret, $i, "name");
}
}
function getStaffListByLID($con,$lid){
global $tidn,$tid,$tpic,$tname;
echo 'ereree'.$lid;
$sel = "select tid,tpic,tname from teacher;";
$ret = pg_Exec($con,$sel);
$tidn = pg_NumRows($ret);
for ( $i=0; $i<$tidn; $i++ ) {
$lid[$i] = pg_Result($ret, $i, "tid");
$lpic{$id[$i]} = pg_Result($ret, $i, "tpic");
$lname{$id[$i]} = pg_Result($ret, $i, "tname");
}
}
global $idn,$id,$pic,$name;
$sel = "select id,pic,name from student;";
$ret = pg_Exec($con,$sel);
$idn = pg_NumRows($ret);
for ( $i=0; $i<$idn; $i++ ) {
$id[$i] = pg_Result($ret, $i, "id");
echo '$id[$i]'.$id[$i];
$lid = $id[$i];
getStaffListByLID($con,$lid);
$pic{$id[$i]} = pg_Result($ret, $i, "pic");
$name{$id[$i]} = pg_Result($ret, $i, "name");
}
}
function getStaffListByLID($con,$lid){
global $tidn,$tid,$tpic,$tname;
echo 'ereree'.$lid;
$sel = "select tid,tpic,tname from teacher;";
$ret = pg_Exec($con,$sel);
$tidn = pg_NumRows($ret);
for ( $i=0; $i<$tidn; $i++ ) {
$lid[$i] = pg_Result($ret, $i, "tid");
$lpic{$id[$i]} = pg_Result($ret, $i, "tpic");
$lname{$id[$i]} = pg_Result($ret, $i, "tname");
}
}
$name{$id[$i]} = pg_Result($ret, $i, "name");
这是什么写法? 你不是有 echo '$id[$i]'.$id[$i];
那么输出结果呢
你在 getStaffListByLID函数里加一句 var_dump($lid);
$this->getStaffListByLID($con,$lid);