When I run this:
echo $user_id; // prints 3
$tags_ids_results = $mysqli->query("SELECT TagID FROM UserTagSubscriptions WHERE UserID = $user_id");
while($tag_id_row = $tags_ids_results->fetch_object()) {
$tag_id = $tag_id_row->TagID;
echo "In While Loop";
}
This only prints "In While Loop" once. However, when I run the query against the database directly (with the same value of $user_id
), three rows are returned.
UPDATE
When I call fetch_all()
on $tags_ids_results
, I get a call to undefined method error (I'm on PHP 5.4). I also get NULL when I print out num_row
.
原来,我在循环的其余部分中重新声明了$tags_ids_results
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.