crud php/mysql

e3bfsja2  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(351)

我正在用mysql做一个php crud,我遇到了一个错误,我已经尝试了几个小时,无法解决,有人能帮我吗?
显示的错误是:
致命错误:在c:\wamp\www\crud\oop\index.php的第233行对字符串调用成员函数fetch\u array()
第233行在while close\数组中,有趣的是表中的第一项显示正常,但其余的没有,我首先有其他代码块是相同的样式,但都正常工作,只有这一个给出了错误

<div class="container">
<div style="height:50px;"></div>
<div class="well" style="margin-left:auto; margin-right:auto; padding:auto; width:70%;">
    <span style="font-size:25px; color:#1f1a2f"><strong>Sorteio</strong></span> <!-- BOTÕES -->
    <span class="pull-right"><a href="#addnewPe" data-toggle="modal" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span> Adicionar</a></span>
    <div style="height:15px;"></div>
    <table class="table table-striped table-bordered table-hover">
        <thead>
        <th>Codigo</th>
        <th>Data pedido</th>
        <th>Cliente</th>
        <th>Funcionário</th>
        <th>Produto</th>
        <th>Quantidade</th>
        <th>Total do pedido</th>
        <th>Ação</th>
        </thead>
        <tbody>
        <?php
        $query=$conn->query("SELECT * FROM tb_pedido Pp INNER JOIN tb_cliente C ON Pp.codCliente = C.codCliente INNER JOIN tb_funcionario F ON Pp.codFuncionario = F.codFuncionario INNER JOIN tb_produto P ON Pp.codProduto = P.codProduto");
        while($row=$query->fetch_array()){
            ?>
            <tr>
                <td><?php echo $row['codPedido']; ?></td>
                <td><?php echo $row['dataPedido']; ?></td>
                <td><?php echo $row['nomeCliente']; ?></td>
                <td><?php echo $row['nomeFuncionario']; ?></td>
                <td><?php echo $row['descricao']; ?></td>
                <td><?php echo $row['qtdVendida']; ?></td>
                <td><?php echo $row['totalPedido']; ?></td>
                <td>
                    <span class="pull-center"><a href="#delPp<?php echo $row['codPedido']; ?>" data-toggle="modal" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a></span>
                    <p>_____</p>
                    <span class="pull-center"><a href="#editPp<?php echo $row['codPedido']; ?>" data-toggle="modal" class="btn btn-warning"><span class="glyphicon glyphicon-edit"></span></a></span>
                    <?php include('pedido/button.php'); ?>
                </td>
            </tr>
            <?php
        }

        ?>
        </tbody>
    </table>
    <?php
    if(isset($_SESSION['msgPp'])){
        ?>
        <div class="alert alert-success">
            <?php echo $_SESSION['msgPp']; ?>
        </div>
        <?php
        unset($_SESSION['msgPp']);
    }
    ?>
</div>
<?php include('pedido/add_modal.php'); ?>

非常感谢你的帮助!

fkaflof6

fkaflof61#

运行查询时始终检查错误。

$sql=$conn->query("SELECT * FROM tb_pedido Pp INNER JOIN tb_cliente C ON Pp.codCliente = C.codCliente INNER JOIN tb_funcionario F ON Pp.codFuncionario = F.codFuncionario INNER JOIN tb_produto P ON Pp.codProduto = P.codProduto");

$res = $mysqli->query($sql) or trigger_error($mysqli->error."[$sql]");

        while($row=$res->fetch_array()){

相关问题