Facebook
From Tacky Rhinoceros, 6 Years ago, written in PHP.
Embed
Download Paste or View Raw
Hits: 262
  1. <?php
  2.  
  3. /*
  4.  * Following code will list all the words
  5.  */
  6.  
  7. // array for JSON response2
  8. $response2 = array();
  9.  
  10. // include db connect class
  11. require_once __DIR__ . '/db_connect.php';
  12.  
  13. // connecting to db
  14. include("db_connect.php");
  15. $con->set_charset ( "utf8" );
  16. $con->query("SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
  17.  
  18.  
  19. // initilize all variable
  20.         $params = $columns = $totalRecords = $data = $dataNew = array();
  21.  
  22.         $params = $_REQUEST;
  23.  
  24.         //define index of column
  25.         $columns = array(
  26.                 0 =>'word',
  27.                 0 =>'id',
  28.                 0 =>'id'
  29.                
  30.         );
  31.         $where = $sqlTot = $sqlRec = "";
  32.  
  33.         if( !empty($params['search']['value']) ) {  
  34.                         $where .=" AND ( not_allowet_words.word LIKE '".$params['search']['value']."%' ";    
  35.                        
  36.         }
  37.  
  38.  
  39.         $sql="SELECT word FROM not_allowet_words";
  40.         $sqlRec .= $sql;
  41.         $sqlTot .= $sql;
  42.  
  43.         if(isset($where) && $where != '') {
  44.  
  45.                 $sqlTot .= $where;
  46.                 $sqlRec .= $where;
  47.                
  48.         }
  49.         $sqlRec .=  " GROUP BY not_allowet_words.id LIMIT ".$params['start']." ,".$params['length']." ";
  50.  
  51.         $queryTot = mysqli_query($con, $sqlTot) or die("database error:". mysqli_error($con));
  52.        
  53.         while( $row = mysqli_fetch_row($queryTot) ) {
  54.                 $totalRecords = $row[0];
  55.         }
  56.         $queryRecords = mysqli_query($con, $sqlTot);
  57.  
  58.         //iterate on results row and create new index array of data
  59.         while( $row = mysqli_fetch_row($queryRecords) ) {
  60.                 $data[] = $row;
  61.         }
  62.        
  63.         while( $row = mysqli_fetch_row($sqlNew) ) {
  64.                 $dataNew[] = $row;
  65.         }
  66.        
  67.         $i=0;
  68.         foreach($data as $d){
  69.                 $data[$i][1] = '111';
  70.                 $data[$i][2] = '222';
  71.                 $i++;
  72.         }
  73.        
  74.        
  75.         $json_data = array(
  76.                         "draw"            => intval( $params['draw'] ),  
  77.                         "recordsTotal"    => $totalRecords ,  
  78.                         "recordsFiltered" => $totalRecords,
  79.                         "data"            => $data   // total data array
  80.                        
  81.                         );
  82.         $json = json_encode($json_data);
  83.         echo $json;   // send data as json format
  84.        
  85.        
  86. ?>