gbengasupowale807 Posted November 6, 2018 Share Posted November 6, 2018 Am trying to put mysqli result set into an array for later use and this is how I did it(but is not working) $split = []; $sql_money = "SELECT j_id, amount_invested FROM j_members WHERE j_activated = 1 LIMIT 5"; $result_money = mysqli_query($conn, $sql_money); while($data = mysqli_fetch_assoc($result_money)){ $split[] = ['id' => $data['id'], 'invest' => $data['amount_invested']]; //echo $data['j_id']; } foreach($split as $s){ echo $s['id'] . '<br>'; } Who can put me through Link to comment Share on other sites More sharing options...
Larry Posted November 6, 2018 Share Posted November 6, 2018 This should do it: $sql_money = "SELECT j_id, amount_invested FROM j_members WHERE j_activated = 1 LIMIT 5"; $result_money = mysqli_query($conn, $sql_money); $split = mysqli_fetch_all($result_money, MYSQLI_ASSOC); Yours wasn't working, by the way, because the query selects j_id and your code refers to $data['id']. Link to comment Share on other sites More sharing options...
Recommended Posts