php get data (post Insert, Update and Delete is in a other file.)
Code:
<?php
include '../include/funktion.php'; // mysql conn etc.
// table
$dbtabelle = 'Menue';
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$sort = isset($_POST['sort']) ? strval($_POST['sort']) : 'Position';
$order = isset($_POST['order']) ? strval($_POST['order']) : 'asc';
$offset = ($page-1)*$rows;
$result = array();
// Suche -------------
if(isset($_POST['Suche']) && !empty($_POST['Suche'])) {
$Suche = mysql_real_escape_string($_POST['Suche']) ;
$where = " WHERE objekt_nr LIKE '%$Suche%'
OR Position LIKE '%$Suche%'
OR Text like '%$Suche%'
OR href like '%$Suche%'
OR onclick like '%$Suche%'
OR icon like '%$Suche%'
OR QEclass like '%$Suche%'
OR data_options like '%$Suche%'
OR Breite like '%$Suche%'
OR target like '%$Suche%' ";
}
else { $where = '';}
// total -------------
$rs = mysql_query("SELECT COUNT(*) FROM $dbtabelle $where");
$row = mysql_fetch_row($rs);
$result["total"] = $row[0];
// rows ---------------
$rs = mysql_query("SELECT * FROM $dbtabelle $where ORDER BY $sort $order LIMIT $offset,$rows");
$items = array();
while($row = mysql_fetch_object($rs)) {
array_push($items, $row);
}
$result["rows"] = $items;
// SUM() for footer --------------------
$rs = mysql_query("SELECT SUM(objekt_nr) AS objekt_nr, SUM(Position) AS Position FROM $dbtabelle $where");
while ($row = mysql_fetch_array($rs)) {
$entry = array( 'objekt_nr' => 'Summe', 'Position' => euro($row['Position']), );
$jsonData[] = $entry;
}
$result["footer"] = $jsonData;
header("Content-type: application/json");
echo json_encode($result);
?>