使用准备好的选择语句遍历行

时间:2019-04-10 11:28:56

标签: php mysql mysqli

我需要使用准备好的语句遍历所有行。不能意识到这一点。它总是显示表格的最后一行。

我已经尝试过:

$stmtprocessors = $conn->prepare("SELECT * FROM products WHERE category='processors'");
$stmtprocessors->execute();
$stmtprocessors->bind_result($id,$name,$description_short,$description_long,$price,$price_vat,$stock,$deleted,$parameters,$purchases,$discount,$category,$reference,$date);

if ($stmtprocessors->num_rows > 0)
{               
    while ($stmtprocessors->fetch()) {
        echo $id;
    }
}

我尝试了print_r($ stmtprocessors),这是结果:

mysqli_stmt Object ( [affected_rows] => -1 [insert_id] => 0 [num_rows] => 0 [param_count] => 0 [field_count] => 14 [errno] => 0 [error] => [error_list] => Array ( ) [sqlstate] => 00000 [id] => 1 )

0 个答案:

没有答案