Hello, Here I am trying to query the information from the DB and display it. But it is not working properly.
I get this error:
Fatal error : Uncaught ArgumentCountError: Too few arguments to function getusers::getUsers(), 0 passed in D:\XAMPP\htdocs\magebit_test\test.php on line 5 and exactly 1 expected in D:\XAMPP\htdocs\magebit_test\database2\getusers.php:7 Stack trace: #0 D:\XAMPP\htdocs\magebit_test\test.php(5): getusers->getUsers() #1 {main} thrown in D:\XAMPP\htdocs\magebit_test\database2\getusers.php on line 7
Please tell me how can I solve this issue.
this is getusers.php class
require "dbconnection.php";
require "userData.php";
class getusers extends dbconnection{
public function getUsers($sql){
$stmt=$this->connect()->prepare($sql);
$stmt->execute();
while ($row = $stmt->fetch()) {
$data[]= new userData($row);
}
if (!empty($data)) {
return $data;
}else{
return null;
}
}
this is test.php class where I am trying to display my query in table.
<?PHP
require "database2/getusers.php";
$users = new getusers();
?>
<?php
$result=$users->getUsers("SELECT * FROM subscribers");
if ($result) {
foreach ($result as $data) {
echo "<tr><td>".$data->getUserId()."</td>";
echo "<td>".$data->getUserEmail()."</td>";
echo "<td>".$data->getUserTime()."</td></tr>";
}
}
?>