I want to call the getStaffListByLID function in the loop of the getStaffListByID function, but the value of lid in getStaffListByLID does not appear to be passed. what can I do? PHPcodefunctiongetStaffListByID ($ con) {global $ idn, $ id, $ pic, $ name; php parameter passing problem
I want to call the getStaffListByLID function in the loop of the getStaffListByLID function, but it seems that the value of lid in getStaffListByLID is not passed. what can I do?
PHP code
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"); } }
------ Solution --------------------
I do not believe
Add a var_dump ($ lid) to the getStaffListByLID function );