我有這段代碼,我想打印一個包含內容的表格。它打印表格,但列是空的...我錯過了什麼?我看不到錯誤..Mysqli查詢不提取結果
function show_autovetture($data){
$con = $data; //PASSO CONNESSIONE
$rows = array(); // PREPARO ARRAY
$stmt = mysqli_stmt_init($con); // INIZIALIZZO LA CONNESSIONE
mysqli_stmt_prepare($stmt,'SELECT
autovetture.id,
autovetture.name
FROM autovetture
ORDER BY id DESC');
or die(mysqli_error($con)); // QUERY INSERIMENTO DATI
mysqli_stmt_execute($stmt); // ESEGUO LA QUERY
mysqli_stmt_bind_result($stmt,$rows['id'],$rows['name']);
$html = "";
$html .= "<div class='container'>";
$html .= "<div class='div_box_5'>";
$html .= "<div class='row'>";
$html .= "<div class='panel panel-default'>";
$html .= "<div class='panel-heading'>";
$html .= "<h4>";
$html .= "Elenco Ditte Autovetture";
$html .= "</h4>";
$html .= "</div> <!-- end panel-heading -->";
$html .= "<table class='table table-fixed'>";
$html .= "<thead>";
$html .= "<tr>";
$html .= "<th class='col-xs-2'>#</th><th class='col-xs-8'>Nome</th><th class='col-xs-2'>Modifica</th>";
$html .= "</tr>";
$html .= "</thead>";
$html .= "<tbody>";
while($rows=mysqli_stmt_fetch($stmt)){
$html .= "<tr>";
$html .= "<td class='col-xs-2'>$rows[id]</td><td class='col-xs-8'>$rows[name]</td><td class='col-xs-2'><a href='edit_autovet.php?id=$rows[id]'><span class='glyphicon glyphicon-pencil'></span></a></td>";
$html .= "</tr>";
}
$html .= "</tbody>";
$html .= "</table>";
$html .= "</div> <!-- end panel panel-default -->";
$html .= "</div> <!-- end row -->";
$html .= "</div> <!-- end div_box_5 -->";
$html .= "</div> <!-- end container -->";
mysqli_stmt_close($stmt); // CHIUDO LO STATEMENT
mysqli_close($con); // CHIUDO CONNESSIONE
return $html;
}
錯誤在哪裏?
閱讀如何檢查mysqli的錯誤 –
的問題是,我有在屏幕上沒有錯誤。我怎麼能檢查他們? –
我發現mysqli有一些學習曲線,但一旦得到它,它就非常健壯。你可以使用http://php.net/mysqli_error'mysqli_error($ link)' –