I have an editable table. I've made functions like loading data, cell editing, adding rows in different PHP scripts and it works. But now I'm trying to make it in one file. I've done so:
PHP Code:
$task = NULL;
if ( isset($_POST['action'])){
$task = $_POST['action'];
}
if ($task == "LOAD") {
Load();
}
switch($task){
case "LOAD":
Load();
mysql_close($link);
break;
case "EDIT":
Edit();
mysql_close($link);
break;
case "ADD":
Add();
mysql_close($link);
break;
default:
echo "{failure:true}";
mysql_close($link);
break;
}
As a result, the table is displayed for a moment and then disappears.
ExtJS code for loading table:
Code:
var itemsPerPage = 30;
var store = Ext.create('Ext.data.Store', {
id:'test',
autoLoad: true,
autoSync: true,
model: 'User',
pageSize: itemsPerPage,
proxy: {
type: 'ajax',
url: 'osnova.php',
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
}
}
});
store.load({
params:{
action: 'LOAD',
start:0,
limit: itemsPerPage
}
});
Loading function in PHP file:
PHP Code:
function Load(){
$num_result = mysql_query ("SELECT * FROM table2") or die (mysql_error());
$totaldata = mysql_num_rows($num_result);
$result=mysql_query ("SELECT * FROM table2 ORDER BY Number LIMIT ".$_POST['start'].", ".$_POST['limit']."") or die (mysql_error ());
$data = array();
while ($row=mysql_fetch_object($result))
{
$data [] = $row;
}
echo '({"total":"'.$totaldata.'","results":'.json_encode($data).'})';
}
I think that the problem in this:
Code:
store.load({
params:{
action: 'LOAD',
start:0,
limit: itemsPerPage
}
});
But I can't understand how to do right.