I have an array called followers and I would like to know how I could get the objectAtIndex $a of the array in PHP.
My current code is this, but it doesn’t work:
$followers = anArray....
$returns = array();
for ($a = 1; $a <= $numberOfFollowers; $a++) {
$follower = $followers[$a];
echo $follower;
$query = mysql_query("query....");
if (!$query) {}
while ($row = mysql_fetch_assoc($query)) {
}
}
edit— This is how I get the followers:
$followers = array();
while ($row = mysql_fetch_array($querys)) {
$followers[] = $row['followingUserID'];
}
$numberOfFollowers = count($followers);
Why not do a
foreach(), like this?I don’t know what you are cooking with this, but to me, this is a huge cannon shooting towards the DB. Try to optimize your queries into a single one. Don’t ever imagine DB fetches with a loop in your mind.