php - mysqli fetch_object returning non-object in the first element of the result set array -


i have particular mysqli query returns empty element @ 0th position in result set array. empty non-object element seems cause problems when try loop through result set display screen

$projareas[] = array(); $projectid = $_get['projectid'];  $sql = "select *         `areas` ,  `project_area_junc`          `areas`.`areaid` =  `project_area_junc`.`areaid`          ,  `project_area_junc`.`projectid` = $projectid";  $results = $conn->query($sql); while($row = $results->fetch_object()) {     $projareas[] = $row;     } 

the result gives unwanted array element @ position 0) i.e. when print_r($projareas) this:

array (     [0] => array         (         )      [1] => stdclass object         (             [areaid] => 56             [propertyid] => 14             [areaname] => living room             [areainfo] =>  lots of windows - colonial style             [proj_area_juncid] => 10             [projectid] => 4         )      [2] => stdclass object         (             [areaid] => 57             [propertyid] => 14             [areaname] => kitchen             [areainfo] =>                [proj_area_juncid] => 11             [projectid] => 4         ) 

try ....

 $projareas = array();     while($row = $results->fetch_object()) {         array_push($projareas ,$row);         }       print_r($projareas); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -