I've problem with my code, the reason, when run query un PHP FILE, this retrieve all records from SELECT * FROM material
, then it pass to JS FILE for process and store all records in an array json format, but display this error:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result
resource in C:\AppServ\www\biblioteca\include\doLogin.php on line 31 []
_
PHP FILE WITH FUNCTIONS
.........
public function searchMat($tipoBusqueda,$terminoBuscar){
$query = " SELECT * FROM material ";
$result = mysql_query($query) or die (mysql_error());
$resultArray = mysql_fetch_assoc($result);
return $resultArray;
}
OTHER PHP FILE with functions
$results = $db->searchMat($tipoBusqueda, $terminoBuscar);
$jsonSearchResults = array();
if ($results != false) {
while($row = mysql_fetch_assoc($results)) {
$jsonSearchResults = array (
'clavemat' => $row['cve_mat'],
'tipomat' => $row['tipo_mat'],
'titulomat' => $row['titulo_mat'],
'autormat' => $row['autor_mat'],
'editmat' => $row['edit_mat'],
'success' => 'success',
);
}
echo json_encode($jsonSearchResults);
}
EDIT: