我遇到了从mySql query
收到的值创建数组的问题。我有以下代码,但我不能用返回的值填充数组。我假设while
语句存在问题。有人可以帮帮我吗?
$return_arr = array();
$searchTerm=$_GET['searchTerm'];
$query = "SELECT Actor.FirstName, Actor.LastName FROM Actors WHERE Actor.ActorFirstName LIKE '%$searchTerm%' ";
$stmt = $db->prepare($query);
$stmt->execute();
$stmt->store_result();
$numrows = $stmt->num_rows;
$stmt->bind_result($firstName, $lastName);
while($row = mysql_fetch_assoc($stmt) {
$return_arr[] = $row['FirstName'];
}
答案 0 :(得分:0)
更改你的while循环
while($ stmt-> fetch())
{
$ return_arr [] = $ firstName;
}