mysql - How to pass variable from a database query to a PHP function -
get_population($row['id']) causing error variable undefined:
foreach($filterlist $row) { echo '<tr>'; echo '<td>' . $row['county_id'] . '</td>'; echo '<td>' . get_population($row['id']) . '</td>'; echo '<td>' . $row['id'] . '</td>'; echo '</tr>'; }
when use database value in function parameter error :undefined variable: must out of scope don't know how around it.
if print $row['id'] shows value of 1 example. if hard code 1 parameter value works. when try pass $row['id'] function error.
i sure simple answer chasing tail. thanks
in code there's mismatch in ''.['id'].'';
the correct $row['id']:
foreach($filterlist $row) { echo '<tr>'; echo '<td>' . $row['county_id'] . '</td>'; echo '<td>' . get_population($row['id']) . '</td>'; // error here echo '<td>' . ['id'] . '</td>'; // change echo '<td>' . $row['id'] . '</td>'; echo '</tr>'; }
Comments
Post a Comment