Guest User

Untitled

a guest
Jul 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. id_Control Primaria Índice int(10)
  2. idctg_turno Índice int(10)
  3. total_horas int(10)
  4. horas_normales int(10)
  5. horas_extras int(10)
  6. Incidencia varchar(1000)
  7. semana int(10)
  8.  
  9. <?php
  10. if($action == 'ajax'){
  11. // escaping, additionally removing everything that could be (html/javascript-) code
  12. $q = mysqli_real_escape_string($con,(strip_tags($_REQUEST['q'], ENT_QUOTES)));
  13. $aColumns = array('semana');//Columnas de busqueda
  14. $sTable = "calculos";
  15. $sWhere = "";
  16. if ( $_GET['q'] != "" )
  17. {
  18. $sWhere = "WHERE (";
  19. for ( $i=0 ; $i<count($aColumns) ; $i++ )
  20. {
  21. $sWhere .= $aColumns[$i]." LIKE '".$q."' OR ";
  22. }
  23. $sWhere = substr_replace( $sWhere, "", -3 );
  24. $sWhere .= ')';
  25. }
  26. $sWhere.=" order by semana ASC";
  27. include 'pagination.php'; //include pagination file
  28. //pagination variables
  29. $page = (isset($_REQUEST['page']) && !empty($_REQUEST['page']))?$_REQUEST['page']:1;
  30. $per_page = 10; //how much records you want to show
  31. $adjacents = 4; //gap between pages after number of adjacents
  32. $offset = ($page - 1) * $per_page;
  33. //Count the total number of row in your table*/
  34. $count_query = mysqli_query($con, "SELECT count(*) AS numrows FROM $sTable $sWhere");
  35. $row= mysqli_fetch_array($count_query);
  36. $numrows = $row['numrows'];
  37. $total_pages = ceil($numrows/$per_page);
  38. $reload = './calculos.php';
  39. //main query to fetch the data
  40. $sql="SELECT * FROM $sTable $sWhere LIMIT $offset,$per_page";
  41. $query = mysqli_query($con, $sql);
  42. //loop through fetched data
  43. if ($numrows>0){
  44.  
  45. ?>
Add Comment
Please, Sign In to add comment