php - Unable to use an array as an array? -
i in process of building software download site company.
however, have come across problem unsure how past.
i retrieving information table particular software release , placing them in multidimensional array. trying run foreach (i have tried loop) against array , error shown below:
when run var dump against original array, this:
so confused don't know i'm missing or going wrong. reason why want run can filter array 1 dimensional array.
below code main web page
<?php //displays list of companies in 2 columns $versionaccess = versionaccess::findaccess($relid);//this gets set earlier in webpage $count = count($versionaccess); var_dump($versionaccess); foreach ($versionaccess $va) { if ($va->company_access != '0') { $versionacc[] = $va->comapny_id; } } foreach ($company $compaccess) { $compaccessid = $compaccess->company_id; if (in_array($compaccessid, $versionacc)) { $access = 'checked disabled'; } else { $access = 'disabled'; } $accessname = 'access'.$compaccessid; if ($ctr % 2 == 0) { echo '<td>'.$compaccess->company_name.':</td>'; echo '<td><label class="switch"><input type="checkbox" name="'.$accessname.'" value="1" '.$access.'><span class="slider round"></span></label></td>'; echo '</tr>'; } else { if ($ctr < $compcount) { echo '<tr>'; echo '<td>'.$compaccess->company_name.':</td>'; echo '<td><label class="switch"><input type="checkbox" name="'.$accessname.'" value="1" '.$access.'><span class="slider round"></span></label></td>'; } else { echo '<tr>'; echo '<td>'.$compaccess->company_name.':</td>'; echo '<td><label class="switch"><input type="checkbox" name="'.$accessname.'" value="1" '.$access.'><span class="slider round"></span></label></td>'; echo '</tr>'; } } $ctr++; } ?>
the function brings data database is:
public static function findaccess($accessid) //find version access in database { return self::findquery("select * version_access version_id = '$accessid'"); }
the findquery method:
public static function findquery($sql) { global $database; $resultset = $database->query($sql); $objectarray = array(); while ($row = mysqli_fetch_array($resultset)) { $objectarray[] = self::instant($row); } return $objectarray; }
i still relatively new , appreciated.
Comments
Post a Comment