how to get data from db using MySQL, PHP and PDO with AJAX

how to get data from db using MySQL, PHP and PDO with AJAX

cris19ncris19n Posts: 55Questions: 18Answers: 0

I have about 8,000 test records and it takes too long to load into the table.

I understand that with ajax I could optimize this process, but I don't know how I can get data from my database, using datatables, PDO, PHP through ajax.

I would appreciate an example:

thanks:

this is the way i use to connect to the db and fetch the sql queries:

   <?php
require_once "conectbd.php";

class ModelShowDt{

   /********************************************************
    SHOW DATAS
   ********************************************************/
   static public function MdlMostrarMaterias($table, $item, $value){

      if($item != null){

         $stmt = Conexion::conect()->prepare("SELECT * FROM $tableWHERE $item = :$item");

         $stmt -> bindParam(":".$item, $value, PDO::PARAM_STR);

         $stmt -> execute();

         return $stmt -> fetch();

      }else{

         $stmt = Conexion::conectar()->prepare("SELECT * FROM $tabla ORDER BY lote_piku_mp desc, viaje_mp ASC");

         $stmt -> execute();

         return $stmt -> fetchAll();
      }

      $stmt -> close();

      $stmt = null;

 }



 }
// end class ModelShowDt

Replies

This discussion has been closed.