Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I am new here and I really need help if something is wrong in the question let me know and I will fix it. Well I'm trying to display all registered tables on a screen of my website and I'm not getting it, I'm using the MVC model so I need an orientation for me to know if I'm doing it right or not. I'm going to send all the classes I'm using for list and the html I use.

HTML Perfil.php

HTML
<form name="formcad" class="needs-validation"  novalidate method="POST" action="PHP/Classes/ListarReserva.php">
<button class="tablink" onclick="openPage('VerReservas', this, 'chocolate')" >Ver Reservas</button>
</form>

<div id="VerReservas" class="tabcontent">

I wish that when he entered this Ver Reservation he could directly display the registered reservations
  
</div>


I wish that when he entered this Ver Reservation he could directly display the registered reservations

ListarReserva.php

PHP
<?php

include 'ReservaDAO.php';
include 'Reserva.php';


$Reserva = new Reserva();

$ReservaDAO = new ReservaDAO();
$ReservaDAO->ListarReservas($Reserva);

?>



ReservaDAO.php

 public static function ListarReservas($Reserva)
    {
        $connection = Connection::getConexao();
        $sql = "SELECT * FROM reserva";
        // Listar Todas as reservas
        $result = mysqli_query($connection, $sql);
        $reservas = array();
        while ($reserva = mysqli_fetch_object($result)) {
            if ($reserva != null) {
                $reservas[] = $reserva;
            }
        }
        return $reservas;
    }
?>


Connection.php

PHP
<?php

include 'ReservaDAO.php';
include 'Reserva.php';


$Reserva = new Reserva();

$ReservaDAO = new ReservaDAO();
$ReservaDAO->ListarReservas($Reserva);

?>


If you need any more data let me know and I'll post it here ok.

What I have tried:

I just tried to give a basic selection for him to display but he does not display and keeps giving this error:


Warning: mysqli_query() expects parameter 1 to be mysqli, object given in C:\wamp64\www\Rapid\PHP\Classes\ReservaDAO.php on line 30


Warning: mysqli_fetch_object() expects parameter 1 to be mysqli_result, null given in C:\wamp64\www\Rapid\PHP\Classes\ReservaDAO.php on line 32
Posted
Updated 25-Mar-20 13:19pm

1 solution

Connection::getConexao() method returns an object where it shoud have returned a mysqli. You did not show the definition of this method.
PHP mysqli connect() Function[^]

The second error message will probably disappear once the first error has been resolved.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900