Add php files
This commit is contained in:
49
Getdata.php
Executable file
49
Getdata.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
////////////////////////////////////////////////////////
|
||||
// DATABASE.PHP
|
||||
////////////////////////////////////////////////////////
|
||||
mysql_connect("localhost", "root", "sgpmk777") or
|
||||
die("Could not connect: " . mysql_error());
|
||||
mysql_select_db("crm");
|
||||
$task = '';
|
||||
getList();
|
||||
if ( isset($_POST['task'])){
|
||||
$task = $_POST['task']; // Get this from Ext
|
||||
}
|
||||
switch($task){
|
||||
case "LISTING": // Give the entire list
|
||||
getList();
|
||||
break;
|
||||
default:
|
||||
echo "{failure:true}"; // Simple 1-dim JSON array to tell Ext the request failed.
|
||||
break;
|
||||
}
|
||||
|
||||
function getList()
|
||||
{
|
||||
$query = "SELECT * FROM PK__12__";
|
||||
$result = mysql_query($query);
|
||||
$nbrows = mysql_num_rows($result);
|
||||
if($nbrows>0){
|
||||
while($rec = mysql_fetch_array($result)){
|
||||
// render the right date format
|
||||
$rec['tookoffice']=codeDate($rec['tookoffice']);
|
||||
$rec['leftoffice']=codeDate($rec['leftoffice']);
|
||||
$arr[] = $rec;
|
||||
$jsonresult = json_encode($arr);
|
||||
echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '({"total":"0", "results":""})';
|
||||
}
|
||||
}
|
||||
|
||||
function codeDate ($date) {
|
||||
$tab = explode ("-", $date);
|
||||
$r = $tab[1]."/".$tab[2]."/".$tab[0];
|
||||
return $r;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user