Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

php mysql get data in array

Hello i want get data in array from the database, i have this code:

$sql = "SELECT * FROM nat WHERE village = '$village'";
$result = $conn->query($sql);


$prname1=array();

while($row = $result->fetch_array()) {
 
    $prname1[]=$row['id_source'];

  }

if call print_r

print_r($prname1);

get back this value:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Array ( [0] => 30000 [1] => 30002 [2] => 30003 )

I need values like this:

[ [0 => 30000], [0 => 30002], [0 => 30003], ]

how to?
Thanks

I try more solutions

>Solution :

Wrap another array around the value when pushing onto the result array.

$prname1[] = [$row['id_source']];
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading