my goal here is to get a variable (with php) and use it in a prepared statement (with mysqli) and then fetch_assoc. For some reason, this code will not work (no errors). I have rtm and I haven’t found anything combining fetch_assoc with prepared statements, so I'm not sure if this is possible. Any help to get this work appreciated, here is my code for now.
$where = $_GET['section'];
$mysqli = mysqli_connect("localhost", "root", "","test");
if($stmt = mysqli_prepare($mysqli,"SELECT title, img, active, price FROM ? ORDER by ID limit 5 ")){
mysqli_stmt_bind_param($stmt, 's', $where);
mysqli_stmt_execute($mysqli);
mysqli_stmt_fetch($mysqli);
while($row = mysqli_fetch_assoc($stmt)){
if($row['active']=="yes"){
echo 'the rest of my stuff goes here';
source
share