$genre = array(
'Action',
'Adventure',
'Fantasy'
);
$selectGenre_sql = 'SELECT genreID FROM genres WHERE dbGenre = ?';
if ($stmt->prepare($selectGenre_sql)) {
// bind the query parameters
$stmt->bind_param('s', $genre);
// bind the results to variables
$stmt->bind_result($genres);
// execute the query
$stmt->execute();
$array1 = array();
while ($stmt->fetch()) {
$array1[] = $genres;
}
}
The code above gets the value from genreID
when dbGenre
is equal to $genre
. And then store the results in an array. But it's not working because $genre
is an array, so I need to loop through it to get a different value from genreID
each time.
The 'genres' table contains two columns: genreID (INT) and dbGenre (VARCHAR)
I just need each genreID (that is a number)... Let's say when dbGenre is equal to Action, then store the genreID in an array1, and then loop the $genre array to get the genreID for the next value and store it again in array1.
How can I fix it?
See Question&Answers more detail:os