php - Attempting to populate two arrays from two tables within a foreach loop -
the end-result of should arrays description , pass should populated , should able echo them. however, descriptions echo passwds not echo. testing, looks $value variable empty result1 query. can not figure out how use $value in second query.
i these 2 errors: notice: undefined variable: pass in /var/www/html/manage/commit.php on line 60 warning: invalid argument supplied foreach() in /var/www/html/manage/commit.php on line 60
// manage.phones $result = mysqli_query($con_manage,"select * phones"); while($row = mysqli_fetch_array($result)) { $mac[] = $row['mac']; $mapped_to[] = $row['mapped_to']; } // asterisk.devices foreach($mapped_to $value) { $result = mysqli_query($con_asterisk,"select description description devices id='$value'"); while($row = mysqli_fetch_array($result)) { $description[] = $row['description']; } $result1 = mysqli_query($con_asterisk,"select data data sip id='$value'"); while($row = mysqli_fetch_array($result)) { $pass[] = $row['data']; } } // echo descriptions , passwds! echo "echo descriptions:"; echo"\n"; foreach($description $key => $value) { echo "$value\n"; } echo "echo passwds:"; echo"\n"; foreach($pass $key => $value) { echo "$value\n"; }
the query select data data sip id='$value'
has en empty result set. that's why $pass[] = $row['data']
never executed. because not define $pass
explicitly (e.g. $pass = array()
before first foreach
loop), 2 errors when trying foreach($pass $key => $value)
.
Comments
Post a Comment