good I'm trying to consult my two tables in the database one is called (payments_page) which is filled with a payment form and the other is (payment_files) which is filled with uploading a csv file. both tables have the same rows and I want to compare the rows (amount and reference) and show in a table those that coin and those that do not match in order to know who paid that month and who did not. Here I leave my code.
<?php
//Clase para manejar la conexion a la base de datos
class Connect
{
private $user = "root";//usuario de mysqlk
private $pass = "";//clave de mysql ( aqui no tengo clave de el servidor)
private $base = "radius";//base de datos en mysql
private $server = "localhost";//servidor de alojamiento
public $error;//en caso de error se almacena aqui
public $db;
public function __construct(){
$mysqli = new mysqli($this->server, $this->user, $this->pass, $this->base);
if ($mysqli->connect_errno) {
$this->error = "Fallo al conectar a MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$this->db = $mysqli;
}
}
//Clase trabajo que se extiende de Connect
class Trabajo extends Connect
{
public function __construct(){
parent::__construct();
}
public function valida($x){
$a = $this->db->query("SELECT * FROM pagos_pagina WHERE referencia = '$x' ");
$t = $a->num_rows();
if($t===1){
//Si el cliente realizó el pago retorno la información
$row = $a->fetch_object();
return $row;
}else{
//si no retorno falso
return false;
}
}//
public function data(){
$a = $this->db->query("SELECT * FROM archivos_pagos");
$row = $a->fetch_array();
foreach($row as $item){
//Envío a validar la referencia del cliente
$valida = $this->valida($item['referencia']);
if($valida){
//Si existe el pago muestro la información
echo "El Cliente ".$item['referencia']." Realizo el pago de ".$valida->monto." en fecha ".$valida->fecha;
}else{
//Si no existe informo que dicho pago no se ha realizado
echo "El Cliente ".$item['referencia']." no ha realizado el pago";
}
}
}
}
$p = new trabajo();
var_dump($p->data());
?>
gives me the following error
(Warning: Illegal string offset 'reference' in C: \ xampp \ htdocs \ superconex \ login \ test.php on line 402) my line 402 is ($ valid = $ this-> validates ($ item ['reference']);) and gives me this error (Fatal error: Call to undefined method mysqli_result :: num_rows () in C: \ xampp \ htdocs \ superconex \ login \ test.php on line 386) my line 386es
($t = $a->num_rows();)
I have tried everything and nothing I can not find what I want, I do not know what I am doing wrong, I beg your great help and enormous knowledge