我的目標是能夠獲得一個變量(使用php)並在準備好的語句(使用mysqli)中使用它,然後使用fetch_assoc。由於某些原因,這段代碼不會工作(沒有錯誤)。我rtm,我還沒有發現任何結合fetch_assoc和預先準備好的語句,所以我不確定是否有可能。任何幫助得到這個工作是讚賞,這裏是我的代碼目前。mysqli用fetch_assoc準備好的語句
$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';
動態表選擇通常是設計不良的指示 –