I'm trying to figure out how to return just an array from a mySQL query with this php code.
The result from the query looks like this.
array(
[0] =>array([0] =>4337)
[1] =>array([0] =>4910)
[2] =>array([0] =>5129)
[3] =>array([0] =>5672)
[4] =>array([0] =>5761)
)
which means I have to reference the value like this $a[$i][0] instead of just $a[$i]
How do I return a single array for a multiple rowset?
I would like the response to look something like this:
array(
[0] =>4337
[1] =>4910
[2] =>5129
[3] =>5672
[4] =>5761
)
Code:
<?php
$query = 'Select myField from myTable where id = "'.$thisValue.'"';
$link = new mysqli("localhost", "my_user", "my_password", "world");
$result = mysqli_query( $link , $query );
$c = mysqli_fetch_all( $result , $resulttype = MYSQLI_NUM );
?>
array(
[0] =>array([0] =>4337)
[1] =>array([0] =>4910)
[2] =>array([0] =>5129)
[3] =>array([0] =>5672)
[4] =>array([0] =>5761)
)
which means I have to reference the value like this $a[$i][0] instead of just $a[$i]
How do I return a single array for a multiple rowset?
I would like the response to look something like this:
array(
[0] =>4337
[1] =>4910
[2] =>5129
[3] =>5672
[4] =>5761
)
Comment